delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
500 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi



Loremo - the 1.5 liter car coming in 2009




Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (2)


Find full path of registered ApplicationsFormat this article printer-friendly!Bookmark function is only available for registered users!
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:
2843
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)






Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
Oops
    Jochen Fromm (Mar 14 2002 10:30AM)

Of course you can also use

Reg.Access := KEY_READ;

I overlooked that.. :-)


Respond

Consider user rights
    Jochen Fromm (Mar 14 2002 10:25AM)

If the user has no administrative rights, access to HKEY_LOCAL_MACHINE is restricted, and this will not work.
Since you are only reading values, you should use

Reg := TRegistry.Create(KEY_READ);  
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
D. Souchard
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)