(* --------------------------------------------
Get *real* file path from a shortcut (*.lnk)
--
Required units: ShlObj, ActiveX
-------------------------------------------- *)
function GetExeFromLink(FileName : String) : String;
var
IntfShelllink : IShellLink;
intfFile : IPersistFile;
fwName : WideString;
DirName : String;
pDirName : PChar;
Data : win32_find_data;
begin
// Get *real* file path from a shortcut (*.lnk)
fwName := FileName;
IntfShelllink := CreateComObject(CLSID_Shelllink) as IShellLink;
intfFile := IntfShelllink as IPersistFile;
intfFile.Load(pwchar(fwname), STGM_READ);
Setlength(DirName, MAX_PATH);
pDirName := PChar(DirName);
IntfShelllink.GetPath(pDirName, max_path, Data, 0);
Result := pDirName;
end;亲试好用。
Delphi:从快捷方式取得文件路径
最新推荐文章于 2026-04-11 16:36:38 发布
本文介绍了一种使用 Delphi 获取 Windows 系统中快捷方式 (*.lnk) 的真实文件路径的方法。通过创建 IShellLink 接口实例并加载指定的快捷方式文件,可以解析出指向的目标文件的完整路径。
403

被折叠的 条评论
为什么被折叠?



