600) this.width = 600;">
procedure CreateShortcutIn(const SpecialFolderCSIDL: integer; const shortcutName : string) ;
var
IObject : IUnknown;
ISLink : IShellLink;
IPFile : IPersistFile;
PIDL : PItemIDList;
InFolder : array[0..MAX_PATH] of Char;
TargetName : String;
LinkName : WideString;
begin
TargetName := ParamStr(0) ;
IObject := CreateComObject(CLSID_ShellLink) ;
ISLink := IObject as IShellLink;
IPFile := IObject as IPersistFile;
with ISLink do
begin
SetPath(pChar(TargetName)) ;
SetWorkingDirectory(pChar(ExtractFilePath(TargetName))) ;
end;
//get the location of the "special folder"
SHGetSpecialFolderLocation(0, SpecialFolderCSIDL, PIDL) ;
SHGetPathFromIDList(PIDL, InFolder) ;
LinkName := Format('%s\%s.lnk',[InFolder, shortcutName]) ;
IPFile.Save(PWChar(LinkName), false) ;
end;
用法示例:CreateShortcutIn(CSIDL_SENDTO,'我的程序') ;
获取发送过来的文件:
procedure TMainForm.FormCreate(Sender: TObject) ;
begin
if ParamCount > 0 then
ShowMessage(ParamStr(1)) ;
end;