CheckRegKey




Private 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
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As _
Long

Const KEY_READ = &H20019 ' ((READ_CONTROL Or KEY_QUERY_VALUE Or
' KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not

' SYNCHRONIZE))


' Return True if a Registry key exists


Function CheckRegistryKey(ByVal hKey As Long, ByVal KeyName As String) As _
Boolean
Dim handle As Long
' Try to open the key

If RegOpenKeyEx(hKey, KeyName, 0, KEY_READ, handle) = 0 Then
' The key exists

CheckRegistryKey = True
' Close it before exiting

RegCloseKey handle
End If
End Function













( checkregkey.html )- by Paolo Puglisi - Modifica del 17/12/2023