function LinkFileInfo(const lnkFileName:string;var info:LINK_FILE_INFO;const bSet:boolean):boolean;var hr:hresult; psl:IShelllink; wfd:win32_find_data; ppf:IPersistFile; lpw:pwidechar; buf:pwidechar;begin result:=false; getmem(buf,MAX_PATH); try if SUCCEEDED(CoInitialize(nil)) then if (succeeded(cocreateinstance(clsid_shelllink,nil,clsctx_inproc_server,IID_IShellLinkA,psl))) then begin hr:=psl.QueryInterface(iPersistFile,ppf); if succeeded(hr) then begin lpw:=stringtowidechar(lnkfilename,buf,MAX_PATH); hr := ppf.Load(lpw, STGM_READ); if succeeded(hr) then begin hr := psl.Resolve(0, SLR_NO_UI); if succeeded(hr) then begin if bSet then begin psl.SetArguments(info.Arguments); psl.SetDescription(info.Description); psl.SetHotkey(info.HotKey); psl.SetIconLocation(info.IconLocation,info.IconIndex); psl.SetIDList(info.ItemIDList); psl.SetPath(info.FileName); psl.SetShowCmd(info.ShowState); psl.SetRelativePath(info.RelativePath,0); psl.SetWorkingDirectory(info.WorkDirectory); result:=succeeded(psl.Resolve(0,SLR_UPDATE)); end else begin psl.GetPath(info.FileName,MAX_PATH, wfd,SLGP_SHORTPATH ); psl.GetIconLocation(info.IconLocation,MAX_PATH,info.IconIndex); psl.GetWorkingDirectory(info.WorkDirectory,MAX_PATH); psl.GetDescription(info.Description,CCH_MAXNAME); psl.GetArguments(info.Arguments,MAX_PATH); psl.GetHotkey(info.HotKey); psl.GetIDList(info.ItemIDList); psl.GetShowCmd(info.ShowState); result:=true; end; end; end; end;end; finally freemem(buf); end;end;
http://expert.csdn.net/Expert/topic/1294/1294027.xml?temp=.7984583