Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Re: VB6 - getting contents of registry entry [modified]

Re: VB6 - getting contents of registry entry [modified]

Scheduled Pinned Locked Moved Visual Basic
htmlcomwindows-adminhelp
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mla154
    wrote on last edited by
    #1

    Hello, I have been trying to get the contents of a registry entry.  I tried the following:

    'http://www.andreavb.com/tip080001.html
    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

    'http://www.windowsdevcenter.com/pub/a/windows/2004/07/27/VB\_Registry\_Values.html
    Private 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

    Private Sub Form_Load()
    RegOpenKeyEx HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", _
    0&, KEY_READ, hKey
    RegQueryValueEx hKey, "CommonFilesDir", 0, 0, sValue, iTemp
    End Sub

    After the RegOpenKeyEx is executed, hKey has a value of 0.  Something doesn't seem right here.  Can anyone help?

    Regards, Mike

    modified on Tuesday, January 22, 2008 9:37:31 AM

    M 1 Reply Last reply
    0
    • M mla154

      Hello, I have been trying to get the contents of a registry entry.  I tried the following:

      'http://www.andreavb.com/tip080001.html
      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

      'http://www.windowsdevcenter.com/pub/a/windows/2004/07/27/VB\_Registry\_Values.html
      Private 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

      Private Sub Form_Load()
      RegOpenKeyEx HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", _
      0&, KEY_READ, hKey
      RegQueryValueEx hKey, "CommonFilesDir", 0, 0, sValue, iTemp
      End Sub

      After the RegOpenKeyEx is executed, hKey has a value of 0.  Something doesn't seem right here.  Can anyone help?

      Regards, Mike

      modified on Tuesday, January 22, 2008 9:37:31 AM

      M Offline
      M Offline
      mla154
      wrote on last edited by
      #2

      I changed Form_Load as shown below:

      Private Sub Form_Load()
      HKEY_LOCAL_MACHINE = &H80000002
      KEY_READ = &H20019
      RegOpenKeyEx HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", _
      0&, KEY_READ, hKey
      RegQueryValueEx hKey, "CommonFilesDir", 0, 0, sValue, iTemp
      End Sub

      Now, I'm getting a non-zero value for hKey, but still I'm getting nothing for sValue.  Anyone have any ideas?

      Regards, Mike

      modified on Tuesday, January 22, 2008 10:49:23 AM

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups