CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 1999
    Posts
    4

    Retrieve some information of WindowsRegistry

    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!


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Retrieve some information of WindowsRegistry

    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





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

Featured