PDA

Click to See Complete Forum and Search --> : Does the value exist in the Registry?


Matthew Howle
May 26th, 2000, 06:30 AM
I was wondering if theres a way to see if a value
exists in a specific place in the registry.


HKEY_CURRENT_USER\Software\APPNAME\SUB\

Name: "Matthew"
Data: "password"

If the name doesn't exist, it comes back as false.

please help, thanks

jim mcnamara
Dec 31st, 2001, 04:03 PM
This function returns 0 if the key exists.


Const REG_SZ = 1 '
Const REG_BINARY = 3 ' Free form binary
Const HKEY_CURRENT_USER = &H80000001
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long


Function RegQueryStringValue ByVal strValueName As String) As Long
Dim hKey as Long
Dim lResult As Long, lValueType As Long, strBuf As String, lDataBufSize As Long
hKey= HKEY_CURRENT_USER
'retrieve nformation about the key
RegQueryStringValue = _
RegQueryValueEx(hKey, strValueName, 0, lValueType, ByVal 0, lDataBufSize)
End Function