type
MyLINK_FILE_INFO = record
TargetFileName : array[0..MAX_PATH] of char; //目标文件名
//WorkDirectory : array[0..MAX_PATH] of char; //工作目录或者起始目录
IconLocation : array[0..MAX_PATH] of char; //图标文件名
IconIndex : integer; //图标索引
Arguments : array[0..MAX_PATH] of char; //程序运行的参数
//Description:array[0..CCH_MAXNAME] of char; //快捷方式的描述
//ItemIDList:PItemIDList; //只供读取使用
//RelativePath:array[0..255] of char; //相对目录,只能设置
//ShowState:integer; //运行时的窗口状态
//HotKey:word; //快捷键
end;
function GetShortcutTarget(const LinkFileName : String; var My_LINK_FILE_INFO : MyLINK_FILE_INFO) : Boolean; //获得快捷方式指向的目标
var
ShellLink : IShellLink;
Buffer: PWideChar;
Win32FindData: WIN32_FIND_DATA;
HResu: HResult;
PersistFile: IPersistFile;
begin
Result:=False;
GetMem(Buffer, MAX_PATH);
if not Succeeded(CoInitialize(nil)) then Exit;
if not Succeeded(coCreateInstance(CLSID_SHELLLINK, nil, CLSCTX_INPROC_SERVER, IID_IShellLinkA, ShellLink)) then Exit;