Results 1 to 3 of 3

Thread: Function doesn't work in my program. [SOLVED]

Threaded View

  1. #1

    Thread Starter
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692

    Function doesn't work in my program. [SOLVED]

    Here is a function I found on the internet:

    VB Code:
    1. 'I put the function inside a module.
    2. Public Sub DoEnumSubKeys(ByVal inMainKey As Long, ByVal inSubKey As String)
    3.     Dim mKey As Long
    4.     Dim mBuffer As String * 256
    5.     Dim mBufSize As Long
    6.     Dim mClassBuffer As String * 256
    7.     Dim mClassBufSize As Long
    8.     Dim typLastWriteTime As FILETIME
    9.     Dim mSubKeyName As String
    10.     Dim mSubKeyValue As String
    11.     Dim mValType As Long
    12.     Dim mIndex As Integer
    13.     Set colSubKeys = New Collection
    14.     If RegOpenKeyEx(inMainKey, inSubKey, 0&, KEY_ALL_ACCESS, mKey) <> 0 Then
    15.         MsgBox "Unable to open a subkey"
    16.         Exit Sub
    17.     End If
    18.     mIndex = 0
    19.     Do
    20.         mClassBuffer = ""
    21.         mClassBufSize = 0
    22.         mBufSize = 256
    23.         mSubKeyName = Space$(mBufSize)
    24.         mResult = RegEnumKeyEx(mKey, mIndex, mSubKeyName, mBufSize, 0, mClassBuffer, mClassBufSize, typLastWriteTime)
    25.         If mResult <> ERR_MORE_DATA And mResult <> 0 Then
    26.              Exit Do
    27.         End If
    28.         mSubKeyName = Left$(mSubKeyName, InStr(mSubKeyName, Chr$(0)) - 1)
    29.         colSubKeys.Add mSubKeyName
    30.         mIndex = mIndex + 1
    31.     Loop
    32.     RegCloseKey mKey
    33.     For i = 1 To colSubKeys.Count
    34.         DoEvents
    35.         If mStopFlag Then
    36.              Exit For
    37.         End If
    38.     Next i
    39.     Set colSubKeys = Nothing
    40. End Sub
    41.  
    42. 'This is in another form.
    43. Private Sub Form_Load()
    44.     DoEnumSubKeys HKEY_LOCAL_MACHINE, "SOFTWARE\Gitmail\Profiles"
    45.     CenterForm Me
    46.     If Profiles.ListCount > 0 Then Delete.Enabled = True
    47.     If colSubKeys.Count > 0 Then Profiles.AddItem colSubKeys(i)
    48. End Sub

    The function was working fine last night, now it refuses to work in my program, yet it will work in any other program. I know I didn't set the colSubKeys variable, but I don't get any errors; just the message box that says it can't open the subkey, and like I said before, it worked great last night. What's wrong?
    Last edited by hothead; Nov 15th, 2003 at 09:36 AM.

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