News:

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

Getting installed applications?

Started by Bieb, May 31, 2005, 05:44:15 PM

Previous topic - Next topic

Bieb

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?

roticv

Registry if I am not wrong.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\

MichaelW

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

eschew obfuscation

Bieb

Wow, that's pretty cool.  Is there such a section of the registry in all versions of Windows?

MichaelW

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.
eschew obfuscation

Bieb

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?

MichaelW

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.
eschew obfuscation

Tedd

See also:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
No snowflake in an avalanche feels responsible.

Bieb

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.

Bieb

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)

MichaelW

eschew obfuscation