간단하게 실행파일 경로만 가져오는 법.
uses
ShlObj, ActiveX;
function GetTargetExe(const LinkFileName: String): String;
var
psl: IShellLink;
ppf: IPersistFile;
info: array [0..MAX_PATH] of Char;
wfs: TWin32FindData;
begin
Result:='';
if not FileExists(LinkfileName) then Exit;
CoCreateInstance(CLSID_SHELLLINK, nil, CLSCTX_INPROC_SERVER, IShellLink, psl);
if psl.QueryInterface(IPersistFile, ppf)=0 then begin
ppf.Load(PWideChar(LinkFileName), STGM_READ);
psl.GetPath((@info), MAX_PATH, wfs, SLGP_UNCPRIORITY);
Result:=info;
end;
end;
ShlObj, ActiveX;
function GetTargetExe(const LinkFileName: String): String;
var
psl: IShellLink;
ppf: IPersistFile;
info: array [0..MAX_PATH] of Char;
wfs: TWin32FindData;
begin
Result:='';
if not FileExists(LinkfileName) then Exit;
CoCreateInstance(CLSID_SHELLLINK, nil, CLSCTX_INPROC_SERVER, IShellLink, psl);
if psl.QueryInterface(IPersistFile, ppf)=0 then begin
ppf.Load(PWideChar(LinkFileName), STGM_READ);
psl.GetPath((@info), MAX_PATH, wfs, SLGP_UNCPRIORITY);
Result:=info;
end;
end;
'Delphi' 카테고리의 다른 글
[Delphi] UAC 권한상승 manifest를 리소스에 포함시켜 컴파일 (UAC requireAdministrator manifest resource file) (6) | 2010.11.23 |
---|---|
[Delphi] 에디트플러스와 DDE 통신 (DDE, EditPlus) (0) | 2010.10.25 |
[Delphi] 디렉토리 생성 (0) | 2010.07.14 |
[Delphi] Listbox Item 선택하기. (List, SendMessage, LB_SETCURSEL, LB_GETITEMRECT) (0) | 2010.07.14 |
[Delphi] DLL의 폼을 Splash 윈도우로 사용하기 (CreateParams) (0) | 2010.07.08 |