triphen
asked on
VB6 reading registry in Win7+
Hello Experts,
I have an application that is supposed to read a registry key and populate a label with it's value. Here is the code:
It works perfect on WinXP but all other OS (7, 2008, 2012) it throws this error:
-------------------------- -
RemoteSupportUpdater
-------------------------- -
Run-time error '-2147024894 (80070002)':
Invalid root in registry key "HKLM\Software\LogMeIn\V5\ WebSvc\Hos tDescripti on".
-------------------------- -
OK
-------------------------- -
But the path does exist in the registry. Any ideas on what I am doing wrong?
I have an application that is supposed to read a registry key and populate a label with it's value. Here is the code:
Dim oReg As Object
Set oReg = CreateObject("WScript.Shell")
lbl_LMIName.Caption = oReg.RegRead("HKLM\Software\LogMeIn\V5\WebSvc\" & "HostDescription")
Set oReg = Nothing
It works perfect on WinXP but all other OS (7, 2008, 2012) it throws this error:
--------------------------
RemoteSupportUpdater
--------------------------
Run-time error '-2147024894 (80070002)':
Invalid root in registry key "HKLM\Software\LogMeIn\V5\
--------------------------
OK
--------------------------
But the path does exist in the registry. Any ideas on what I am doing wrong?
This could be a permissions error. Try running your script by right clicking and using "Run as Administrator"
ASKER
Sorry for delayed response. Yes I have tried that. Same problem
Would I be right in guessing that the 7, 2008, 2012 machines are x64 whereas the XP machine is x32.
If this is correct then what is happening is that when using a 32 bit application on x64 machine you get redirected to the Wow6432Node key by default.
https://msdn.microsoft.com/en-us/library/aa384129(v=vs.85).aspx
If this is correct then what is happening is that when using a 32 bit application on x64 machine you get redirected to the Wow6432Node key by default.
https://msdn.microsoft.com/en-us/library/aa384129(v=vs.85).aspx
ASKER
Sorry for the delay. Was in the hospital :/
Thanks for this. I am using
GetRegValue("HKEY_LOCAL_MA CHINE", "Software\LogMeIn\V5\WebSv c", "HostDescription")
But it errors with "Type Mismatch"
Thanks for this. I am using
Public Function GetRegValue(RootKey As HKEYS, sKey As String, sValueName As String) As Variant
Dim hKeyHandle As Long
Dim vTemp As Variant
Call RegOpenKeyEx(RootKey, sKey, 0&, lngKEY_ALL_ACCESS, hKeyHandle)
ReadRegistryValue hKeyHandle, sValueName, vTemp
Call RegCloseKey(hKeyHandle)
GetRegValue = vTemp
End Function
GetRegValue("HKEY_LOCAL_MA
But it errors with "Type Mismatch"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nice, thank you!
Now a new problem....I get Runtime -7 "Out of memory" when running on Server 2008 or Server 2012. Works fine on XP and 7.
Now a new problem....I get Runtime -7 "Out of memory" when running on Server 2008 or Server 2012. Works fine on XP and 7.
hmm not sure. This could be permissions, try running the script with "Run as an Administrator" even if you are logged in with Admin rights.
ASKER
Still no good. I will open a new question. Thanks!