Link to home
Start Free TrialLog in
Avatar of asdf103100
asdf103100

asked on

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).
Avatar of bukko
bukko


Use WScript.Shell

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

bukko

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

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
ASKER CERTIFIED SOLUTION
Avatar of J-Man
J-Man

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of asdf103100

ASKER

what does the script do? also its comming back with the problem that the key is not found
what does the script do? also its comming back with the problem that the key is not found
this is a perfect example, thank you.
what does the script do? also its comming back with the problem that the key is not found