|
-
Aug 20th, 2001, 09:36 AM
#1
Thread Starter
Retired VBF Adm1nistrator
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]
-
Aug 20th, 2001, 09:47 AM
#2
PowerPoster
It looks like it is, and you can gt the names using this code...
In a module...
VB Code:
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HKEY_PERFORMANCE_DATA = &H80000004
Public Const HKEY_CURRENT_CONFIG = &H80000005
Public Const HKEY_DYN_DATA = &H80000006
Public Const REG_SZ = 1 ' Unicode nul terminated string
Public Const REG_BINARY = 3 ' Free form binary
Public Const REG_DWORD = 4 ' 32-bit number
Public Const ERROR_SUCCESS = 0&
Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
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
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
Public Function GetAllKeys(hKey As Long, strPath As String) As Variant
' Returns: an array in a variant of strings
Dim lRegResult As Long
Dim lCounter As Long
Dim hCurKey As Long
Dim strBuffer As String
Dim lDataBufferSize As Long
Dim strNames() As String
Dim intZeroPos As Integer
lCounter = 0
lRegResult = RegOpenKey(hKey, strPath, hCurKey)
Do
'initialise buffers (longest possible length=255)
lDataBufferSize = 255
strBuffer = String(lDataBufferSize, " ")
lRegResult = RegEnumKey(hCurKey, lCounter, strBuffer, lDataBufferSize)
If lRegResult = ERROR_SUCCESS Then
'tidy up string and save it
ReDim Preserve strNames(lCounter) As String
intZeroPos = InStr(strBuffer, Chr$(0))
If intZeroPos > 0 Then
strNames(UBound(strNames)) = Left$(strBuffer, intZeroPos - 1)
Else
strNames(UBound(strNames)) = strBuffer
End If
lCounter = lCounter + 1
Else
Exit Do
End If
Loop
GetAllKeys = strNames
End Function
Usage: (Don't forget the listbox!)
VB Code:
Private Sub Command1_Click()
Dim SubKeys As Variant
Dim KeyLoop As Integer
Dim KeyName As String
SubKeys = GetAllKeys(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Uninstall")
If VarType(SubKeys) = vbArray + vbString Then
For KeyLoop = 0 To UBound(SubKeys)
KeyName = SubKeys(KeyLoop)
List1.AddItem KeyName
Next
End If
End Sub
-
Aug 20th, 2001, 10:01 AM
#3
Thread Starter
Retired VBF Adm1nistrator
Chris, not looking for a job in Ireland by any chance are you ?
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 20th, 2001, 10:03 AM
#4
PowerPoster
Well the Guiness is better in Ireland apparently...
-
Oct 18th, 2001, 08:58 AM
#5
Thread Starter
Retired VBF Adm1nistrator
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]
-
Oct 19th, 2001, 10:52 AM
#6
PowerPoster
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...
-
Oct 19th, 2001, 10:59 AM
#7
Thread Starter
Retired VBF Adm1nistrator
Check your ass, you seem to be sticking everything else there lately
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Oct 19th, 2001, 11:01 AM
#8
PowerPoster
Including that damn brick...man I should never have done that
-
Oct 19th, 2001, 11:03 AM
#9
Thread Starter
Retired VBF Adm1nistrator
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|