请问各位大哥哥,如何读出windows桌面上的快捷方式?(100分)

  • 主题发起人 主题发起人 Col
  • 开始时间 开始时间
C

Col

Unregistered / Unconfirmed
GUEST, unregistred user!
现在我想读出windows桌面上的快捷方式,我知道首先应该获得桌面的句柄<br>&nbsp; DestTopHandle:=GetDesktopWindow;<br>&nbsp; 然后呢?各位大哥哥指点指点
 
MSDN里面看Win32_ShortcutFile
 
function GetShortcutTarget(ShortcutFilename:string):string; <br>var <br>Psl:IShellLink; <br>Ppf:IPersistFile; <br>WideName:Array [0..MAX_PATH] of WideChar; <br>pResult:Array [0..MAX_PATH-1] Of Char; <br>Data:TWin32FindData; <br>const <br>IID_IPersistFile: TGUID = ( <br>&nbsp; D1:$0000010B; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46)); <br>begin <br>CoCreateInstance(CLSID_ShellLink,nil,CLSCTX_INPROC_SERVER, IID_IShellLinkA ,psl); <br>psl.QueryInterface(IID_IPersistFile,ppf); <br>MultiByteToWideChar(CP_ACP, 0, pChar(ShortcutFilename), -1, WideName, Max_Path); <br>ppf.Load(WideName,STGM_READ); <br>psl.Resolve(0,SLR_ANY_MATCH); <br>psl.GetPath( @pResult,MAX_PATH,Data,SLGP_UNCPRIORITY); <br>Result:=StrPas(@pResult); <br>end; <br>用法:<br>form1.caption:=GetShortcutTarget('c:/windows/profiles/user1/desktop/visitme.pif');
 
请问<br>&nbsp; mantousoft:<br>Psl:IShellLink; <br>Ppf:IPersistFile; <br>在哪里定义的,我不知道应该uses哪个文件
 
uses activex,shlobj,comobj;<br><br>var<br>&nbsp; iilist:PITEMIDLIST;<br>&nbsp; path:array[0..MAX_PATH]of char;<br>&nbsp; ishlnk:IShellLink;<br>&nbsp; ipfile:IPersistFile;<br>&nbsp; fn:WideString;<br>&nbsp; fd:TWin32FindData;<br>begin<br>SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,iilist);<br>SHGetPathFromIDList(iilist,path); //这里得到桌面所在的目录<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //比如 c:/windows/desktop之类的,与系统有关<br><br>ishlnk:=CreateCOMObject(CLSID_ShellLink) as IShellLink;<br>ipfile:=ishlnk as IPersistFile;<br>fn:=string(path)+'/WINAMP.lnk'; //这里以桌面上的 WINAMP.lnk 为例<br>ipfile.Load(PWideChar(fn),0);<br>ishlnk.GetPath(path,MAX_PATH,fd,0);<br>ShowMessage(path); //这个就是链接的文件<br>end;<br><br>上面代码全是我刚写的,版权所有<br>
 
pipi<br>&nbsp; 谢谢你先!<br>&nbsp; 但我想列出所有的超连接,而且还包括如“我的电脑”等,不仅仅是显示,而是跟在桌面上一样,如点<br>右键,可以Popup一个一样的PoupuMenu,再努力一下
 
后退
顶部