Results 1 to 9 of 9

Thread: re; Installed programs from registry

  1. #1

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    re; Installed programs from registry

    Howdy.

    Just wondering is the list of programs installed on the $current$ computer always listed here :

    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall


    And if so, is there a way of enumerating through that list of crap ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    It looks like it is, and you can gt the names using this code...

    In a module...
    VB Code:
    1. Public Const HKEY_CLASSES_ROOT = &H80000000
    2. Public Const HKEY_CURRENT_USER = &H80000001
    3. Public Const HKEY_LOCAL_MACHINE = &H80000002
    4. Public Const HKEY_USERS = &H80000003
    5. Public Const HKEY_PERFORMANCE_DATA = &H80000004
    6. Public Const HKEY_CURRENT_CONFIG = &H80000005
    7. Public Const HKEY_DYN_DATA = &H80000006
    8. Public Const REG_SZ = 1                         ' Unicode nul terminated string
    9. Public Const REG_BINARY = 3                     ' Free form binary
    10. Public Const REG_DWORD = 4                      ' 32-bit number
    11. Public Const ERROR_SUCCESS = 0&
    12.  
    13. Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    14. Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    15. Public Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
    16. Public Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, lpReserved As Long, lpType As Long, lpData As Byte, lpcbData As Long) As Long
    17. Public Function GetAllKeys(hKey As Long, strPath As String) As Variant
    18. ' Returns: an array in a variant of strings
    19.  
    20. Dim lRegResult As Long
    21. Dim lCounter As Long
    22. Dim hCurKey As Long
    23. Dim strBuffer As String
    24. Dim lDataBufferSize As Long
    25. Dim strNames() As String
    26. Dim intZeroPos As Integer
    27.  
    28. lCounter = 0
    29.  
    30. lRegResult = RegOpenKey(hKey, strPath, hCurKey)
    31.  
    32. Do
    33.  
    34.   'initialise buffers (longest possible length=255)
    35.   lDataBufferSize = 255
    36.   strBuffer = String(lDataBufferSize, " ")
    37.   lRegResult = RegEnumKey(hCurKey, lCounter, strBuffer, lDataBufferSize)
    38.  
    39.   If lRegResult = ERROR_SUCCESS Then
    40.  
    41.     'tidy up string and save it
    42.     ReDim Preserve strNames(lCounter) As String
    43.    
    44.     intZeroPos = InStr(strBuffer, Chr$(0))
    45.     If intZeroPos > 0 Then
    46.       strNames(UBound(strNames)) = Left$(strBuffer, intZeroPos - 1)
    47.     Else
    48.       strNames(UBound(strNames)) = strBuffer
    49.     End If
    50.  
    51.     lCounter = lCounter + 1
    52.  
    53.   Else
    54.     Exit Do
    55.   End If
    56. Loop
    57.  
    58. GetAllKeys = strNames
    59.  
    60. End Function
    Usage: (Don't forget the listbox!)
    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3. Dim SubKeys As Variant
    4. Dim KeyLoop As Integer
    5. Dim KeyName As String
    6.  
    7. SubKeys = GetAllKeys(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Uninstall")
    8.  
    9. If VarType(SubKeys) = vbArray + vbString Then
    10.     For KeyLoop = 0 To UBound(SubKeys)
    11.         KeyName = SubKeys(KeyLoop)
    12.         List1.AddItem KeyName
    13.     Next
    14. End If
    15.  
    16. End Sub

  3. #3

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Chris, not looking for a job in Ireland by any chance are you ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Well the Guiness is better in Ireland apparently...

  5. #5

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Is there any easy way of accessing the keys contained within each of those folder jobbies returned by that lot above ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  6. #6
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    You know that, that is indeed very possible but you'll have to hang for a while cause I have no idea where my old code snippets have gone...

  7. #7

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Check your ass, you seem to be sticking everything else there lately
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  8. #8
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Including that damn brick...man I should never have done that

  9. #9

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    teeheehee a pile of bricks ...


    uhn why do i bother
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width