|
-
Feb 8th, 2011, 03:37 PM
#1
Thread Starter
New Member
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?
-
Feb 8th, 2011, 04:22 PM
#2
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.
-
Feb 8th, 2011, 06:00 PM
#3
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.
-
Feb 8th, 2011, 06:08 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|