Results 1 to 4 of 4

Thread: VB6 and Windows 2008/7 Registry

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    1

    VB6 and Windows 2008/7 Registry

    Hi folks,
    I've recently updated an app that was written in vb6 many moons ago - this app is now being deployed on a 2008 server, and is running into problems accessing the system registry.

    I was originally accessing the registry using:

    Dim oReg as New Registry
    oReg.getKeyValue(HKEY_LOCAL_MACHINE,<keypath>,<keyname>,"")

    this returns nothing for the last parameter, which is meant to be the return type, suggesting that it cannot find the registry key. I have checked all the paths, multiple times over the last few hours, so im convinced that they are correct.

    I then tried using regread by creating a Wscript.shell. This works only as far as reading a particular value on the HKLM node - any subnodes seem to throw up an error saying "Invalid root in registry Key".

    At a bit of a loss on what to try now - it almost seems as if the HKLM constant within the Registry class in vb6 translates to a hex location that doesnt work with Windows 2008.

    Lastly, I tried RegOpenKeyEx, but am struggling to figure out the 4th parameter - samDesired. As per MSDN, something like Key_READ should work, but vb6 doesnt seem to know the value of this - i have declared the function with advapi32.dll, so not sure if something else is needed to use RegOpenKeyEx?

    Otherwise I'm out of ideas - is there anything else that can be done to access a windows 2008 registry setting from within VB6?

    PS: thanks in advance...

    Is there any other way to access the registry of a Windows 2008 machine, but through VB6?

  2. #2
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: VB6 and Windows 2008/7 Registry

    You might look at AllApi's RegOpenKeyEx page and examples. Sorry I can't be more specific.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: VB6 and Windows 2008/7 Registry

    Your first example may be using the old Microsoft RegObj Library. This was never kept current and Microsoft doesn't offer the source to permit updating it, and it is becoming less and less useful over time.

    The registry has gone through many changes over the past 15 years. Registry reflection, virtualization, and redirection have been added as the complexity of the Windows ecosystem has grown along with the need to protect the registry from malware.


    Your current problem may be due more to running under a 64-bit edition of Windows than the particular version of Windows.

    The API call will probably work with the right Security Access Mask but wthout knowing which key you're trying to read it is hard to be more specific. You may need to set the KEY_WOW64_64KEY bit in the mask if what you're after is a key in the 64-bit view of HKLM, which would normally be obscured for VB6 programs.

  4. #4
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: VB6 and Windows 2008/7 Registry

    For RegOpenKeyEx try setting the samDesired flag to KEY_ALL_ACCESS Or KEY_WOW64_64KEY

    The constant values are
    Code:
    Private Const KEY_ALL_ACCESS        As Long = &H3F
    Private Const KEY_WOW64_64KEY       As Long = &H100
    
    Dim lngFlag as Long
    
    lngFlag = KEY_ALL_ACCESS Or KEY_WOW64_64KEY

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