来自:o*o 时间:2000-1-21 17:08:50 ID:178552
function ReadLink(AFileName: String):String;
var
psl: IShellLink;
ppf: IPersistFile;
WCLinkName: array[0..Max_Path] of WideChar;
Buf: array[0..255] of Char;
Data: TWin32FindData;
begin
psl:=CreateComObject(CLSID_ShellLink) as IShellLink;
ppf:=psl as IPersistFile;
StringToWideChar(AFileName, WCLinkName, MAX_PATH);
ppf.Load(WCLinkName, STGM_READ);
psl.GetPath(@Buf, Max_Path, Data, SLGP_UNCPRIORITY);
Result := StrPas(Buf);
end;
用法:filename:=ReadLink('aaaa.lnk'); 可以得到.lnk指向的文件名。
// Add by wjiachun;
//千万记得 uses shlobj;
//否则你会发现ppf: IPersistFile;定义错误