hmustak
01/12/2002, 01:47
procedure desktopShortcut(ffilename:string; fcaption: widestring);
var
IObject : IUnknown;
ISLink : IShellLink;
IPFile : IPersistFile;
PIDL : PItemIDList;
InFolder : array[0..MAX_PATH] of Char;
TargetName : String;
LinkName : WideString;
FLinkName : String;
begin
TargetName := ffilename;
IObject := CreateComObject(CLSID_ShellLink);
ISLink := IObject as IShellLink;
IPFile := IObject as IPersistFile;
with ISLink do begin
SetPath(pChar(TargetName));
SetWorkingDirectory
(pChar(ExtractFilePath(TargetName)));
end;
SHGetSpecialFolderLocation
(0, CSIDL_DESKTOPDIRECTORY, PIDL);
SHGetPathFromIDList
(PIDL, InFolder);
FlinkName := '\'+ FCaption + '.lnk';
LinkName := InFolder + FlinkName;
IPFile.Save(PWChar(LinkName), false);
end;
//Kullanımı:
DesktopShortcut('C:/sedatatif/hmustak.exe','Notepad');
@sedat
Senin şu topikdeki soru için modifiye edilebilir gibi :)
var
IObject : IUnknown;
ISLink : IShellLink;
IPFile : IPersistFile;
PIDL : PItemIDList;
InFolder : array[0..MAX_PATH] of Char;
TargetName : String;
LinkName : WideString;
FLinkName : String;
begin
TargetName := ffilename;
IObject := CreateComObject(CLSID_ShellLink);
ISLink := IObject as IShellLink;
IPFile := IObject as IPersistFile;
with ISLink do begin
SetPath(pChar(TargetName));
SetWorkingDirectory
(pChar(ExtractFilePath(TargetName)));
end;
SHGetSpecialFolderLocation
(0, CSIDL_DESKTOPDIRECTORY, PIDL);
SHGetPathFromIDList
(PIDL, InFolder);
FlinkName := '\'+ FCaption + '.lnk';
LinkName := InFolder + FlinkName;
IPFile.Save(PWChar(LinkName), false);
end;
//Kullanımı:
DesktopShortcut('C:/sedatatif/hmustak.exe','Notepad');
@sedat
Senin şu topikdeki soru için modifiye edilebilir gibi :)