Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Read a Value From Windows Registry? 1

Status
Not open for further replies.

VicRauch

Programmer
Sep 26, 2004
242
0
0
US
I am trying to read a certain entry from the windows registry, but not having much luck. I have found a VB routine to read the entry, but I have not been able to find EXACTLY what entries to make in the parameters in order to get this routine to return the value from the registry.

The VB routine can be viewed here.

Any ideas on what to put in which parameters for the RegGetValue$() function?

Thanks,
Vic
 
PHV,
Thanks for the quick response. I've read through that link to Microsoft.com but have not found any reference in there about what values are to go into the parameters of the function I'm trying to use. I also do not see any reference to what to put into the parameters of the functions discussed in the article. That is where I'm having the problem, that is, what to put into the parameters so the function, any function, will return the value I'm looking for in the registry.

What is "MainKey&", and what is "SubKey$", and what is "value$"? I'm assuming that "value$" is used for putting a value into the registry. I'm also assuming that "MainKey&" is a numeric value that refers to HKEY_LOCAL_MACHINE, OR HKEY_CURENT_USER, or the other high level starting points in the registry. And I'm assuming that SubKey$ will hold the tree portion of the key, like "Software\Audacity\Audacity\mp3\mp3LibPath". But this is not working: RegGetValue$(HKEY_CURRENT_USER, "Software\Audacity\Audacity\mp3", "")

Can you see what I'm doing wrong with these parameters?
 
OK, I've looked at the link and found this piece of code that looks like it is to be used to read registry key values using WMI:
Code:
const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set oReg=GetObject( _
   "winmgmts:{impersonationLevel=impersonate}!\\" &_
    strComputer & "\root\default:StdRegProv")
strKeyPath = "Console"
strValueName = "HistoryBufferSize"
oReg.GetDWORDValue _
   HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
WScript.Echo "Current History Buffer Size: " & dwValue
What is WMI? What is "winmgmts:{impersonationLevel=impersonate}!\\" and what is "\root\default:StdRegProv") and how do they correspond with
HKEY_CURRENT_USER, "Software\Audacity\Audacity\mp3"

All I know at this point is that I want to read the value from "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\PortNumber"

I could use regedit, but I'm 90 miles from the computers, so giving my client a small program that can read this value from all their computers will be much easier than driving the 3 hour round trip.

Is there someone that can explain this stuff cause I'm just getting more lost. I will be doing this within an Access database, as I'm not a VB programmer.
 
And what about this ?
strName = "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\PortNumber"
MsgBox CreateObject("WScript.Shell").RegRead(strName)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yes, that works! Thank you very much!

Now, any idea why the function I was trying would not work? Do you see anything that I could change so it would work?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top