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> 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');