|
| Find full path of registered Applications | 
|
|---|
| using the Registry | Product: Delphi all versions | Category: Files Operation | Skill Level:
 | Scoring:  | Last Update: 03/13/2002 | Search Keys: delphi delphi3000 article borland vcl code-snippet REGSTR_PATH_APPPATHS registry applicationpath notepad KEY_READ OpenKey CloseKey ReadString | Times Scored: 2 | Visits: 3446 | Uploader: Andreas Schmidt Company: | Reference: N/A | | | Question/Problem/Abstract:
Open the windows start menu -> execute and type in:
wordpad
This will start the WordPad. But how does this work?
Some Applications are registered in the Registry.
e.g.: dialer, WinWord, Excel, mplayer, Winzip, .... | Answer:
uses Registry, RegStr;
function TrueExecutablePath(const path:string):string;
var
Reg: TRegistry;
begin
result := path;
if not FileExists(path) then
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
Reg.Access := KEY_READ;
if Reg.OpenKey(REGSTR_PATH_APPPATHS+'\'+path, False) or
Reg.OpenKey(REGSTR_PATH_APPPATHS+'\'+path+'.exe',False) then
result := Reg.ReadString('')
finally
Reg.CloseKey;
Reg.Free;
end;
end;
end;
see also article 1007.
please drop me a mail, if there is a shell function,
with scans the search paths too. (there must be one,
because the shell searches the registry and the search paths)
|
|