oversky
September 12th, 1999, 12:17 AM
Hi!
If you give me an answer to this question, you will make a happy man!
How can I retrive information of the Registry in VB?
Thanks!
Lothar Haensler
September 13th, 1999, 01:46 AM
if VB 6 you can use VBA.GetSetting(s) command to get application specific information from the registry.
To access any key use the following APIs:
RegOpenKey, ReqQueryValue, RegCloseKey
check out this sample
public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (byval hKey as Long, byval lpSubKey as string, byval ulOptions as Long, byval samDesired as Long, phkResult as Long) as Long
public 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
public Declare Function RegCloseKey Lib "advapi32.dll" (byval hKey as Long) as Long
public Const HKEY_LOCAL_MACHINE = &H80000002
public Const HKEY_CURRENT_USER = &H80000001
public Const REG_SZ = 1
public Const KEY_QUERY_VALUE = &H1
Dim hKey as Long
Dim lResult as Long
Dim dwType as Long
Dim dwLen as Long
Const REGKEY = "SoftWare\VB and VBA Program settings\QSAddin\Settings"
lResult = RegOpenKeyEx(HKEY_CURRENT_USER, REGKEY, vbNull, KEY_QUERY_VALUE, hKey)
If (lResult <> 0) then
MsgBox "cannot open key"
Exit Sub
End If
dwLen = 9
dwType = REG_SZ
Dim strapp as string
strapp = string(10, " ")
lResult = RegQueryValueEx(hKey, "DisplayOnConnect", _
0, dwType, byval strapp, dwLen)
If dwLen > 0 then
strapp = mid(strapp, dwLen - 1)
End If
RegCloseKey hKey
MsgBox strapp