创建桌面快捷方式
procedure desktopMenu(StartupFilename, lnkname: String);
var
  tmpObject: IUnknown;
  tmpSLink: IShellLink;
  tmpPFile: IPersistFile;
  PIDL: PItemIDList;
  StartupDirectory: array[0..MAX_PATH] of Char;
  LinkFilename: WideString;
  c1:THandle;
begin
  tmpObject := CreateComObject(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 + lnkname;
  tmpPFile.Save(pWChar(LinkFilename),FALSE);
  c1 := windows.FindWindowEx(windows.FindWindowEx(windows.FindWindow('Progman','Program Manager'),0,'SHELLDLL_DefView',''),0,'SysListView32','');
  PostMessage(c1,WM_KEYDOWN,VK_F5,0);
  PostMessage(c1,WM_KEYUP,VK_F5,1 shl 31);
end; 
阅读更多
文章标签: manager string path c
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

创建桌面快捷方式

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭