Hello!
I've a problem with the 'RegEnumKey'-Function. The function succeeds(it returns 0) but the third parameter(which returns the name of the subkey) is always empty!
:( :confused:
Printable View
Hello!
I've a problem with the 'RegEnumKey'-Function. The function succeeds(it returns 0) but the third parameter(which returns the name of the subkey) is always empty!
:( :confused:
Hello,
I hope this code helps you but I'm in a bit of a rush at the moment so I haven't checked it through correctly. Just add a command button to a form and paste the code in.
Hope it helps,Code:Option Explicit
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private 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
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Const HKEY_CURRENT_USER = &H80000001
Private Sub Command1_Click()
GetAllSubKeys
End Sub
Function GetAllSubKeys()
Dim lResult As Long
Dim lRegKey As Long
Dim sBuff As String
Dim lBuffSize As Long
Dim lValue As Long
lResult = RegOpenKey(HKEY_CURRENT_USER, "RemoteAccess\Profile", lRegKey)
If lResult <> 0 Then Exit Function
lValue = 0
sBuff = Space(255)
lBuffSize = 255
While RegEnumKey(lRegKey, lValue, sBuff, lBuffSize) = 0
Debug.Print Left(sBuff, lBuffSize)
sBuff = Space(255)
lBuffSize = 255
lValue = lValue + 1
Wend
lResult = RegCloseKey(lRegKey)
End Function
Desire
Yes, your code really helped me. Thank you!!