Click to See Complete Forum and Search --> : Registry Gurus Please Help Me!


pavan
December 10th, 1998, 06:54 PM
Hi frineds,

I would like to enumerate all the keys under HKEY_CLASSES_ROOT\CLSID\

and put them in a collection or variant array .

Can any one help me with the code how to achieve it?

Afterwards i would like to traverse the collection using "for each next" and do

my own stuff on that.

If any one knows how to use the API RegEnumValue() in a loop so that

i can enumerate all the keys under HKEY_CLASSES_ROOT\CLSID\, pl tell me.

If possible please help me with the sample code in VB.

Thanking you.

With Regards

pavan

Sven Olof Olsen
May 18th, 1999, 04:31 AM
Hello

You can use a code similar to the one below, this function will return an array of keys;

Public Function RegEnumKey(HandleToKeyToEnumerate As Long)
Dim lResult As Long
Dim lCurIdx As Long
Dim strValue As String
Dim lLenOfData As Long
Dim strClass As String
Dim lClassLen As Long
Dim lFileTime As FILETIME
Dim aResult() As String

lCurIdx = 0
Do
lLenOfData = 256
strValue = String(lLenOfData, 0)
lClassLen = 256
strClass = String(lClassLen, 0)

lResult = RegEnumKeyEx(HandleToKeyToEnumerate, _
lCurIdx, _
ByVal strValue, _
lLenOfData, _
0&, _
ByVal strClass, _
lClassLen, _
lFileTime)

If lResult = ERROR_SUCCESS Then
ReDim Preserve aResult(lCurIdx)
aResult(lCurIdx) = Left$(strValue, lLenOfData)
End If
lCurIdx = lCurIdx + 1

Loop While lResult = ERROR_SUCCESS
RegEnumKey = aResult
End Function