Results 1 to 4 of 4

Thread: Find All Products

  1. #1

    Thread Starter
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    Find All Products

    I got code from this forum that will list out all of the installed Microsoft Office Apps, but I'd like to be able to list EVERY installed application on my machine.

    Any ideas how I would do that?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. 'Written by Tygur
    2. 'Original link: [url]http://www.vbforums.com/showthread.php?s=&threadid=152777[/url]
    3. Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
    4. Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
    5. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    6. Private Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As FILETIME) As Long
    7.  
    8. Private Const HKEY_LOCAL_MACHINE = &H80000002
    9. Private Const KEY_QUERY_VALUE = &H1
    10. Private Const KEY_ENUMERATE_SUB_KEYS = &H8
    11. Private Const ERROR_NO_MORE_ITEMS = 259&
    12. Private Const REG_SZ = 1
    13. Private Type FILETIME
    14.         dwLowDateTime As Long
    15.         dwHighDateTime As Long
    16. End Type
    17.  
    18. Private RetArray() As String
    19.  
    20.  
    21. Private Function GetInstalledApps() As String()
    22.  
    23. Dim hParentKey As Long
    24. Dim hSubKey As Long
    25. Dim lIndex As Long
    26. Dim sAppID As String
    27. Dim lAppID As Long
    28. Dim sAppName As String
    29. Dim lAppName As Long
    30. Dim ValueType As Long
    31. Dim DummyTime As FILETIME
    32. Dim UbRetArray As Long
    33. Dim sErr As String
    34. Dim lErr As Long
    35.  
    36. UbRetArray = -1
    37. If RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Uninstall", 0, KEY_ENUMERATE_SUB_KEYS, hParentKey) = 0 Then
    38.     sAppID = Space(64)
    39.     lAppID = 64
    40.     Do While RegEnumKeyEx(hParentKey, lIndex, sAppID, lAppID, 0, vbNullString, 0, DummyTime) = 0
    41.         sAppID = Left(sAppID, lAppID)
    42.         If RegOpenKeyEx(hParentKey, sAppID, 0, KEY_QUERY_VALUE, hSubKey) = 0 Then
    43.             lAppName = 0
    44.             If RegQueryValueEx(hSubKey, "DisplayName", 0, ValueType, ByVal 0, lAppName) = 0 Then
    45.                 If ValueType = REG_SZ Then
    46.                     sAppName = Space(lAppName)
    47.                     RegQueryValueEx hSubKey, "DisplayName", 0, 0, ByVal sAppName, lAppName
    48.                     sAppName = Left(sAppName, lAppName - 1)
    49.                     UbRetArray = UbRetArray + 1
    50.                     ReDim Preserve RetArray(UbRetArray)
    51.                     RetArray(UbRetArray) = sAppName
    52.                 End If
    53.             End If
    54.             RegCloseKey hSubKey
    55.             hSubKey = 0
    56.         End If
    57.         lIndex = lIndex + 1
    58.         sAppID = Space(64)
    59.         lAppID = 64
    60.     Loop
    61.     RegCloseKey hParentKey
    62. End If
    63. GetInstalledApps = RetArray
    64. End Function
    65.  
    66. Private Sub Command1_Click()
    67. GetInstalledApps
    68. Dim i As Long
    69. For i = LBound(RetArray) To UBound(RetArray)
    70.     List1.AddItem RetArray(i)
    71. Next
    72. End Sub

  3. #3
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    For major applications that register with windows, there's probably an API call that would help you out, but remember, many small apps don't register or show up on window's radar at all so I don't think there's likely anything you can do to ferret them out other than do a search for all EXE files and that's not going to give you exactly the list you're looking for

  4. #4

    Thread Starter
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    Thumbs up

    For major applications that register with windows, there's probably an API call that would help you out, but remember, many small apps don't register or show up on window's radar at all so I don't think there's likely anything you can do to ferret them out other than do a search for all EXE files and that's not going to give you exactly the list you're looking for
    True, but the code Hack posted should do just fine.

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