Test existence hodnoty v registru

Postup:
V modulu nadeklarujte:

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 

Function CheckRegistryKey(ByVal hKey As Long, ByVal KeyName As String)_
As Boolean 
' Vrátí True, pokud hodnota v registru existuje  

   Dim handle As Long 
   
' Pokus o otevření registru 
   If RegOpenKeyEx(hKey, KeyName, 0, KEY_READ, handle) = 0 Then 
      
' Hodnota existuje 
      CheckRegistryKey = True 
      
'Zavření registru 
      RegCloseKey handle 
   End If 

End Function

Zpět

Autor: The Bozena