//在桌面上建立快捷方式<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>tmpObject : IUnknown;<br>tmpSLink : IShellLink;<br>tmpPFile : IPersistFile;<br>PIDL : PItemIDList;<br>StartupDirectory : array[0..MAX_PATH] of Char;<br>StartupFilename : String;<br>LinkFilename : WideString;<br>begin<br>StartupFilename := 'c:/windows/notepad.exe';<br>tmpObject := CreateComObject(CLSID_ShellLink);//创建建立快捷方式的外壳扩展<br>tmpSLink := tmpObject as IShellLink;//取得接口<br>tmpPFile := tmpObject as IPersistFile;//用来储存*.lnk文件的接口<br>tmpSLink.SetPath(pChar(StartupFilename));//设定notepad.exe所在路径<br>tmpSLink.SetWorkingDirectory(pChar(ExtractFilePath(StartupFilename)));//设定工作目录<br>SHGetSpecialFolderLocation(0,<br>CSIDL_DESKTOPDIRECTORY,<br>PIDL);//获得桌面的Itemidlist<br>SHGetPathFromIDList(PIDL,<br>StartupDirectory);//获得桌面路径<br>LinkFilename := StartupDirectory + '/MyNotepad.lnk';<br>tmpPFile.Save(pWChar(LinkFilename),FALSE);//保存*.lnk文件<br>end;