Delphi 根据快捷方式路径取源文件地址


本文整理自网络,侵删。

  uses shlobj,ActiveX,ComObj;



function TForm1.ExeFromLink(const linkname: string): string;
var
link: IShellLink;
storage: IPersistFile;
filedata: TWin32FindData;
buf: Array[0..MAX_PATH] of Char;
widepath: WideString;
begin
OleCheck(CoCreateInstance(CLSID_ShellLink, nil, CLSCTX_INPROC_SERVER, IShellLink, link));
OleCheck(link.QueryInterface(IPersistFile, storage));
widepath := linkname;
Result := 'unable to resolve link';
If Succeeded(storage.Load(@widepath[1], STGM_READ)) Then
If Succeeded(link.Resolve(GetActiveWindow, SLR_NOUPDATE)) Then
If Succeeded(link.GetPath(buf, sizeof(buf), filedata, SLGP_UNCPRIORITY)) Then
Result := buf;
storage := nil;
link:= nil;
end;



//调用方法

procedure TForm1.Button2Click(Sender: TObject);
begin

//edit3.text:='C:\Documents and Settings\hjh\桌面\OA客户端.lnk';
Edit4.Text:=ExeFromLink(edit3.Text);

//Edit4.text:='D:\Program Files\OA客户端\OAUpdate.exe';
end;

相关阅读 >>

Delphi json

Delphi iddecodermime 对图像编码base64解码成图像文件

Delphi 检测url地址是否有效

Delphi int64 与 currency

Delphi sqlite 简明上手指南

Delphi vclskin 5.40在2010安装方法

Delphi 获取image.picture.data的数据

Delphi idhttp中get与post的区别

Delphi 获取/设置桌面窗口样式的Delphi代码

Delphi 动态数组的使用

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...