home *** CD-ROM | disk | FTP | other *** search
-
- Private Function RegRetrieve() As String
-
- Dim lonSubkeyHandle As Long
- Dim lonStatus As Long
- Dim lonValueType As Long
- Dim lonValueSize As Long
-
- ' Use the GetSubkeyHandle function to determine the
- ' handle of the subkey given in txtSectionName.
- lonSubkeyHandle = GetSubkeyHandle(txtSectionName.Text)
- If lonSubkeyHandle = -1 Then
- ' Subkey could not be located.
- RegRetrieve = "Error - Subkey could not be located"
- Exit Function
- End If
-
- ' Use the RegQueryValueEx API function to retrieve
- ' the value of the key given in txtKeyName.
- lonValueType = REG_SZ
- lonValueSize = 256
- lonStatus = RegQueryValueEx(lonSubkeyHandle, _
- Trim$(txtKeyName.Text), 0, lonValueType, _
- ByVal gstrKeyValue, lonValueSize)
- If lonStatus <> 0 Then
- ' Key could not be located.
- RegRetrieve = "Error - Key could not be located"
- Else
- RegRetrieve = "Key retrieved successfully"
- txtValue.Text = Left$(gstrKeyValue, lonValueSize)
- End If
-
- ' Close the open subkey with the CloseSubKey
- ' function.
- lonStatus = CloseSubkey(lonSubkeyHandle)
-
- End Function
-