//请自己根据需要修改
procedure AddLink;
var
tmpObject : IUnknown;
tmpSLink : IShellLink;
tmpPFile : IPersistFile;
PIDL : PItemIDList;
StartupDirectory : array[0..MAX_PATH] of Char;
LinkFilename : WideString;
linkshortname:string;
begin
tmpObject := CreateComObject(CLSID_ShellLink);//创建建立快捷方式的外壳扩展
tmpSLink := tmpObject as IShellLink;//取得接口
tmpPFile := tmpObject as IPersistFile;//用来储存*.lnk文件的接口
tmpSLink.SetPath(pChar(ExtractFilePath(application.exename)+ExtractFileName(Application.ExeName)));
//设定nFolder所在路径
tmpSLink.SetWorkingDirectory(pChar(ExtractFilePath(application.exename)));//设定工作目录
SHGetSpecialFolderLocation(0,CSIDL_DESKTOPDIRECTORY,PIDL); //获得桌面的Itemidlist
SHGetPathFromIDList(PIDL,StartupDirectory);//获得桌面路径
//linkshortname:=Copy(ExtractFileName(Application.ExeName),0,Length(ExtractFileName(Application.ExeName))-4);
linkshortname:='2017居民医保登记' ;
LinkFilename := string(StartupDirectory)+'\'+linkshortname+'.lnk';
tmpPFile.Save(pWChar(LinkFilename),FALSE);
//保存*.lnk文件
//showmessage('已经成功添加快捷方式'''+linkshortname+'.lnk''!');
end;
url 快捷方式文件的内容像INI文件一样,
[InternetShortcut]
URL="http://www.baidu.com"
IconFile=D:\Program\WebApplication\Images\favicon.ico
IconIndex=0