Results 1 to 8 of 8

Thread: Registry key Exists [Resolved]

Threaded View

  1. #1

    Thread Starter
    Fanatic Member MikkyThomeon's Avatar
    Join Date
    Oct 2002
    Location
    At work...
    Posts
    648

    Registry key Exists [Resolved]

    I have searched the other posts but they do not work for this key:


    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MySQL Connector/ODBC 3.51


    I have tried using this code:

    VB Code:
    1. Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" _
    2.     (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, _
    3.     ByVal samDesired As Long, phkResult As Long) As Long
    4.  
    5. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As _
    6.     Long
    7.    
    8. Const KEY_READ = &H20019
    9. Const HKEY_CLASSES_ROOT = &H80000000
    10. Const HKEY_CURRENT_CONFIG = &H80000005
    11. Const HKEY_CURRENT_USER = &H80000001
    12. Const HKEY_LOCAL_MACHINE = &H80000002
    13. Const HKEY_USERS = &H80000003
    14.  
    15. ' Return True if a Registry key exists
    16.  
    17. Public Function CheckRegistryKey(ByVal hKey As Long, ByVal KeyName As String) As Boolean
    18.     Dim handle As Long
    19.     ' Try to open the key
    20.     If RegOpenKeyEx(hKey, KeyName, 0, KEY_READ, handle) = 0 Then
    21.         ' The key exists
    22.         CheckRegistryKey = True
    23.         ' Close it before exiting
    24.         RegCloseKey handle
    25.     End If
    26. End Function


    How can I check if the key actually exists???
    Last edited by MikkyThomeon; Feb 26th, 2004 at 12:40 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width