News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to find installed programs directory?

Started by RedXVII, March 18, 2006, 02:28:02 AM

Previous topic - Next topic

RedXVII

I want to run an installed program but i dont know the directory; the user might have changed it from the default to something they like :/

In order to run it, i need to find where it is. So how do i find it? Does windows list the directories of installed programs somewhere? If so, what function(s) would i call to retireve it?

Cheers  :U

arafel

Most installers add entry in HKEY_ LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\[appname] for unistallation purposes. A full path to unistaller is placed there, so the path to the installation dir could be obtained from it.

Also if the application is using registry for data storing check it's entry, there might be installation path specified somewhere.

RedXVII


Tedd

I would use "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\..." instead.
The uninstall entries may not give the correct path to the program (can be rundll, or an installer in windows\system, etc) if they even give a path at all.

Also, both of these methods require that the application is installed correctly, and has added the relevant entry into the resgistry. (But you want to run an installed program, so it should be okay.)
No snowflake in an avalanche feels responsible.

jckl

i use code very simular to whats below to get the path to a game directory.



.Data
   DFPath          db 256 dup(0)
   DFKeyName       db "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\df.exe",0
   DFSubKeyName    db "Path",0


GetDFPath Proc
   LOCAL buffsize:DWORD
   LOCAL hKey:DWORD
   LOCAL keyType:DWORD

   invoke RegOpenKeyEx,HKEY_LOCAL_MACHINE,addr DFKeyName,0,KEY_QUERY_VALUE,addr hKey
   test eax,eax
   jnz None
   mov buffsize,255
   invoke RegQueryValueEx,hKey,addr DFSubKeyName,0,addr keyType,addr DFPath,addr buffsize
   test eax,eax
   jz Done
   ' Here you would put the code which says there was no key found
   jmp Done
  None:
   ' Here you would put the code which says there was no subkey found
  Done:
   Invoke RegCloseKey,hKey
   ret
GetDFPath endp

zooba

Quote from: jckl on March 20, 2006, 10:52:57 AM
i use code very simular to whats below to get the path to a game directory.

If you only want to run the program and it's stored in App Paths then you can just run it from anywhere. It's one of the places that gets searched.

Of course, if you want other files from the same place you'll have to do what jckl has done :U