Reading and Righting to registry

Hey i have been trying to find everywhere a good tutorial that would actualy work for me but unfortunately i have not been able to what i want to do is open up a key in the registry using visual basics api.  What i want to open up is the key located under HKEY_CURRENT_USER\Valve\Half-Life\InstallPath and then get the install path from there.   What im lookin for in the answer is an exmple piece of code that will get that also its a reg_sv variable just incase you need to know for the answer.  What i want is an example with the appropriat comments that will get that and teach me how to input that data OR a website that will tell me how (must work for vb 6.0).
asdf103100Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bukkoCommented:

Use WScript.Shell

...I'll put some code together and post.

bukko
0
bukkoCommented:

Public Function GetRegValue( strRegPath As String ) As String
    Dim objWSH As Object
   
    Set objWSH = CreateObject("WScript.Shell")
    GetRegValue = objWSH.RegRead( strRegPath )
   
    Set objWSH = Nothing

End Function


To use...

MyValue = GetRegValue("HKEY_CURRENT_USER\Valve\Half-Life\InstallPath")
Debug.Print MyValue


Regards

bukko
0
bukkoCommented:

To write...

Public Function SetRegValue( strRegPath As String, strValue As String ) As String
   Dim objWSH As Object
   
   Set objWSH = CreateObject("WScript.Shell")
   objWSH.RegWrite strRegPath, strValue
   
   Set objWSH = Nothing

End Function

To use...

SetRegValue "HKEY_CURRENT_USER\Valve\Half-Life\InstallPath", strMyValue

Regards

bukko
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

J-ManCommented:
http://www.freevbcode.com/ShowCode.Asp?ID=314

This website has excellent example code for registry functions with windows api.
For your case you need to know the two functions: RegOpenKey, and RegQueryValueEx.
Constant enumerations are also listed for key locataions (i.e. HKEY_CURRENT_USER), access rights, value types, and return codes.

This is a large example with code to check if a key exists, create, read, write and delete keys/values.

Enjoy.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
asdf103100Author Commented:
what does the script do? also its comming back with the problem that the key is not found
0
asdf103100Author Commented:
what does the script do? also its comming back with the problem that the key is not found
0
asdf103100Author Commented:
this is a perfect example, thank you.
0
asdf103100Author Commented:
what does the script do? also its comming back with the problem that the key is not found
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.