创建快捷方式

首先添加shlobj单元

procedure CreateLink(ExePath,LinkName:WideString);

var

tmpObject:IUnknown;

tmpSLink:IShellLink;

PIDL:PItemIDList;

tmpPFile:IPersistFile;

StartupDirectory:array[0..MAXPATH] of char;

LinkFileName:widestring;

begin

StartupFileName:=ExePath;

tmpObject:=CreateObject(CLSID_ShellLink);

tmpSLink:=tmpObject as IShellLink;

tmpPFile:=tmpObject as IPersistFile;

tmpSLink.SetPath(pchar(StartupFileName));

tmpSLink.SetWorkingDirectory(pchar(ExtractFilePath(StartupFileName)));

SHGetSpecialFolderLocation(0,CSIDL_DESKTOPDIRECTORY,PIDL);

SHGetPathFromIDList(PIDL,StartupDirectory);

LinkFileName:=StartupDirectory;

LinFileName:=LinkFileName+'\'+LinkName+'.lnk';

tmpFFile.Save(pchar(LinkFileName),FALSE);

end;

上一篇:如何一站式解决“人财物事”管理难题?


下一篇:六种调用shell命令的方法