Help needed with Registry sub-keys 
Author Message
 Help needed with Registry sub-keys

Greetings

Could someone please let me know how to accomplish the following:

I need to retrieve UNKNOWN Sub-Keys from a Registry Key ie

HKEY_CURRENT_USERS
       SOFTWARE
             <KEY>   <SUB-KEY1>      <DWORD Data etc>
                           <SUB-KEY2>
                           <SUB-KEY3>

I do not need the DWORD data to the right of the Sub-Key.

Any help is greatly appreciated.

--
Kind regards,
    Tony Jones, Gold Coast, Queensland, Australia
    Southern Cross Visual Basic Code and Links
    http://www.*-*-*.com/ ~scvb/index.html

    (If ' http://www.*-*-*.com/ ~scvb/...' fails, please use
' http://www.*-*-*.com/ ')



Sat, 17 Jun 2000 03:00:00 GMT  
 Help needed with Registry sub-keys



Quote:
> Greetings

> Could someone please let me know how to accomplish the following:

> I need to retrieve UNKNOWN Sub-Keys from a Registry Key

To enumerate (find a list of) the subkeys in a registry path, you use the
RegEnumKey API function.  To enumerate the values in a key (and the
associated data) you would use the RegEnumValue function.  Attached to this
message is a .frm file which demonstrates the use of RegEnumKey and
RegEnumValue.  Please note that as I wrote this demo in about 15 minutes, I
can't get the bug out of the RegEnumValue function.  RegEnumKey works fine.
 RegEnumValue always wants to return error 87 ("The parameter is
incorrect").

I've looked at the info on RegEnumKey in MSDN, but no avail... the API
obviously doesn't like something that I am doing.

Anybody wanna pick up the ball that I've dropped?   :-)

------------
Jim Houghtaling

email:  hmm... no.
web:   working on it (heh)
platform(s):  Win95 os/r2, WinNT 4.0 sp3, VB5ee sp3
('till I get my page up go to VBNet...It's the best I've seen yet.)
http://home.sprynet.com/sprynet/rasanen/vbnet/default.htm
------------
Imitation may be the sincerest form of flattery,
but you take-a my stuff, I break-a you face.  :-)



Sun, 18 Jun 2000 03:00:00 GMT  
 Help needed with Registry sub-keys

I implemented RegEnumKeyEx for this purpose as follows.

Iteratively call getkeyname, incrementing the value of dwIndex until the
return is Null.
'***************  Code Start  *******************
Private Declare Function RegOpenKeyEx Lib "advapi32" Alias _
      "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, _
      ByVal dwReserved As Long, ByVal samDesired As Long, phkResult _
      As Long) As Long
Private Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias
"RegEnumKeyExA" _
      (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, _
      lpcbName As Long, lpReserved As Long, ByVal lpClass As String, _
      lpcbClass As Long, lpftLastWriteTime As FILETIME) As Long

Function GetKeyName(hInKey As Long, ByVal subkey$, dwIndex As Long)
  Dim hKey As Long
  Dim lpName As String
  Dim lpcbName As Long
  Dim lpReserved As Long
  Dim lpClass As String
  Dim lpcbClass As Long
  Dim lpftLastWriteTime As FILETIME
  Dim lngRet As Long
  Dim hSubKey As Long
  'Dim RetVal$, , dwType As Long, SZ As Long
  Const KEY_ALL_ACCESS As Long = &HF0063
  Const ERROR_SUCCESS As Long = 0
  Const REG_SZ As Long = 1
  hKey = RegOpenKeyEx(hInKey, subkey$, 0, KEY_ALL_ACCESS, hSubKey)
  If hKey <> ERROR_SUCCESS Then MsgBox "{*filter*}"
  lpcbName = 256
  lpName = String$(lpcbName, 0)
  lpReserved = 0
  lpClass = String$(1, 0)
  lpcbClass = 0

  lngRet = RegEnumKeyEx(hSubKey, dwIndex, lpName, lpcbName, lpReserved, _
           lpClass, lpcbClass, lpftLastWriteTime)
  GetKeyName = Left(lpName, lpcbName)
End Function
'***************  Code End  *********************
I called the code above like this to fill a list box with the names of the
installed printers

'Code snippet
  Dim lngX As Long
  Dim strTemp As String
  Dim strMsg As String
  lngX = 0
  Do
    strTemp = GetKeyName(HKEY_CURRENT_CONFIG, _
      "System\CurrentControlSet\Control\Print\Printers", lngX)
    If Left(strTemp, 1) <> Chr$(0) Then
      List1.AddItem strTemp
      lngX = lngX + 1
    End If
    strTemp = Left(strTemp, 1)
  Loop Until strTemp = Chr$(0)

Quote:

>Greetings

>Could someone please let me know how to accomplish the following:

>I need to retrieve UNKNOWN Sub-Keys from a Registry Key ie

>HKEY_CURRENT_USERS
>       SOFTWARE
>             <KEY>   <SUB-KEY1>      <DWORD Data etc>
>                           <SUB-KEY2>
>                           <SUB-KEY3>

>I do not need the DWORD data to the right of the Sub-Key.

>Any help is greatly appreciated.

>--
>Kind regards,
>    Tony Jones, Gold Coast, Queensland, Australia
>    Southern Cross Visual Basic Code and Links
>     http://www.*-*-*.com/ ~scvb/index.html

>    (If ' http://www.*-*-*.com/ ~scvb/...' fails, please use
>' http://www.*-*-*.com/ ')



Thu, 22 Jun 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. find the specify Root key and Sub key from the registry

2. Deleting Registry key and sub-keys?

3. Renaming or copying a registry key and its sub-keys

4. read (all) subkeys of a given registry key ?

5. Enumerating Registry sub-keys?

6. Enumerating Registry sub-keys?

7. Enumerating Registry sub-keys?

8. Reading all subkeys of a certain key from registry

9. VB 4.0 and Getting Registry Sub Keys

10. Need help with registry keys real urgent!

11. enum registry subkeys using winAPI32 registry functions

12. find the specify Root Key and Sub Key

 

 
Powered by phpBB® Forum Software