Registry Checker

I have problem on my program.  How do i know if the registry subkey exist using Visual Basic 2005. I have here a code in Visual Basic 6.0, I don't know how use it in Visual Basic 2005.  Can you please help me

Example:

'=============================================================
' This is a Visual Basic 6.0 code example
'=============================================================


Public Function
DoesKeyExist(ByVal lngRootKey As Long, _
                                        ByVal strRegKeyPath As String) As Boolean
    
        Dim lngKeyHandle As Long

        lngKeyHandle = 0
 
        m_lngRetVal = RegOpenKey(lngRootKey, strRegKeyPath, lngKeyHandle)
   
        If lngKeyHandle = 0 Then
            DoesKeyExist = False
       
Else
            DoesKeyExist = True
        End If
 
        m_lngRetVal = RegCloseKey(lngKeyHandle)
 
End Function


==> How can i use this in Visual Basic 2005



Answer this question

Registry Checker

  • plshn99

    Thank you ver much, but i made a little revision of the code you gave to me.  All I need is to check if the "Mytoolbar" subkey of "HKEY_CURRENT_USER\Software" is existing, so I revised it into:


    Private
    Function IsKeythere() As Boolean

    Const cFullRegistryRoot As String"HKey_Current_User\Software\Mytoolbar"

    Const cRegistryAppSubkey As String""


    If
    My.Computer.Registry.GetValue(cFullRegistryRoot, cRegistryAppSubkey, "KeyIsPresent") <> "KeyIsPresent" Then

    IsKeythere = false

    Else

    IsKeythere = true

    End If

    End Function


    Thank you so much :)


  • Klaus-Dieter

    Private Function IsKeythere() As Boolean


    Const cFullRegistryRoot As String"HKey_Current_User\Software\"

    Const cRegistryAppSubkey As String"Mytoolbar"


    If
    My.Computer.Registry.GetValue(cFullRegistryRoot, cRegistryAppSubkey, "KeyIsPresent") <> "KeyIsPresent" Then

    IsKeythere = false

    Else

    IsKeythere = true

    End If

    End Function



  • kebabbert

    It was my intention to supply you with a useable example that will fit your needs. I'm glad it helped. :)


  • Registry Checker