The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Bieb on May 31, 2005, 05:44:15 PM

Title: Getting installed applications?
Post by: Bieb on May 31, 2005, 05:44:15 PM
How, exactly, would I go about trying to find a list of all the installed programs on a system?  Is there an API function for it, or would I have to dig through the registry?
Title: Re: Getting installed applications?
Post by: roticv on June 01, 2005, 03:01:58 AM
Registry if I am not wrong.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
Title: Re: Getting installed applications?
Post by: MichaelW on June 01, 2005, 05:30:10 AM
You could do both -- dig through the registry using the API :toothy

; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .486                       ; create 32 bit code
    .model flat, stdcall       ; 32 bit memory model
    option casemap :none       ; case sensitive

    include \masm32\include\windows.inc
    include \masm32\include\masm32.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\advapi32.inc
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\kernel32.lib
    includelib \masm32\lib\advapi32.lib
    include \masm32\macros\macros.asm

    _FILETIME STRUCT
        dwLowDateTime   DWORD ?
        dwHighDateTime  DWORD ?
    _FILETIME ENDS

    NAME_SIZE EQU 16384

    SUBKEY EQU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
      lastWriteTime  _FILETIME <>
      hKey          dd 0
      cbKeyName     dd NAME_SIZE
      keyName       db NAME_SIZE dup(0)
      subKey        db SUBKEY,0
    .code
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    invoke RegOpenKeyEx,HKEY_LOCAL_MACHINE,ADDR subKey,0,
                        KEY_ALL_ACCESS,ADDR hKey 
    xor   ebx,ebx
    .REPEAT
        invoke RegEnumKeyEx,hKey,ebx,ADDR keyName,ADDR cbKeyName,
                            NULL,NULL,NULL,ADDR lastWriteTime
        Switch eax
          Case ERROR_NO_MORE_ITEMS
            .BREAK
          Case ERROR_MORE_DATA
            print chr$("name buffer too small",13,10)
            .BREAK
          Case ERROR_SUCCESS
            print ADDR keyName,13,10
          Default
            print chr$("unexpected error",13,10)
            .BREAK
        EndSw
        mov   cbKeyName,NAME_SIZE
        inc   ebx
    .UNTIL 0

    mov   eax,input(13,10,"Press enter to exit...")
    exit
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start

Title: Re: Getting installed applications?
Post by: Bieb on June 01, 2005, 10:22:12 PM
Wow, that's pretty cool.  Is there such a section of the registry in all versions of Windows?
Title: Re: Getting installed applications?
Post by: MichaelW on June 01, 2005, 10:49:48 PM
If by section you mean the Uninstall subkey, I think it is present in all versions starting at least with Windows 95 OSR2, and possibly earlier.
Title: Re: Getting installed applications?
Post by: Bieb on June 01, 2005, 11:49:46 PM
Thanks.  I just realized that I have a problem, though.  I need to be able to find out how to run all the installed applications, but that subkey will only have information on how to uninstall them.  Is there one somewhere that will give me the executable path?
Title: Re: Getting installed applications?
Post by: MichaelW on June 02, 2005, 02:06:59 AM
Many of the components in Uninstall are not executable in the normal sense. The same goes for subkey "App Paths". I'm having problems imagining why you would want to do this.
Title: Re: Getting installed applications?
Post by: Tedd on June 02, 2005, 12:23:28 PM
See also:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
Title: Re: Getting installed applications?
Post by: Bieb on June 02, 2005, 03:02:07 PM
Thanks, I'll take a look at it.  I'm basically trying to make a replacement for the Start menu.  It would be ideal, of course, if the user didn't have to type in the name and executable path of every application they want to be able to run.
Title: Re: Getting installed applications?
Post by: Bieb on June 09, 2005, 08:51:54 PM
One more question.  I've gotten a routine written to find all the subkeys in a key, but how do I get a value from the subkeys? (I already know it's title and type)
Title: Re: Getting installed applications?
Post by: MichaelW on June 09, 2005, 11:24:42 PM
I posted two examples here:

http://www.masmforum.com/simple/index.php?topic=1745.0