关闭

创建桌面快捷方式

312人阅读 评论(0) 收藏 举报
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; 
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:9267次
    • 积分:219
    • 等级:
    • 排名:千里之外
    • 原创:10篇
    • 转载:6篇
    • 译文:0篇
    • 评论:1条
    文章存档
    最新评论