Creating registry values (using Regobj.dll) 
Author Message
 Creating registry values (using Regobj.dll)

Hi guys,
     For a program I'm writing, I use a lot of values stored in the
registry which are edited by my setup program.  I'm using Regobj.dll to
edit the registry because it will let me go anywhere in the registry and
SaveSetting restricts to the Local User.  My problem is this, when I
install it on a new computer that the values are not yet created, I get an
error telling me just that.  The RegSetValue sub is supposed to check if
the branch exists and create it with the RegCreateValue function if it
doesn't.  For some reason, this doesn't work.  And I'm not able to figure
out how the code works, let alone try and fix it.  Any help would be
greatly appreciated!

Brad

Sub RegSetValue(MainKey$, SubKey$, ValueName$, ValueString)

On Error GoTo RegSetValue_Err
Dim objRegKey As RegKey
Dim sCompl As String
Dim bRet As Boolean

'Make sure the SubKey and ValueName already exist in the registry
bRet = RegCreateValue(MainKey, SubKey, ValueName, ValueString)

'Now it is OK to set the value
sCompl = "\" & MainKey & "\" & SubKey
Set objRegKey = RegKeyFromString(sCompl)
objRegKey.Values(ValueName).Value = ValueString
Exit Sub

RegSetValue_Err:
End Sub

Function RegCreateValue(MainKey$, SubKey$, ValueName$, ValueString) As
Boolean

'This function creates a registry key & value.  It must not already exist
'STRING values only!
'All errors are ignored in case the key exists
On Error Resume Next
Dim objRegKey As RegKey
Dim sCompl As String
sCompl = "\" & MainKey & "\" & SubKey
Set objRegKey = RegKeyFromString(sCompl)
objRegKey.Values.Add ValueName, ValueString, RegValueType.rvString
RegCreateValue = False

End Function



Mon, 01 Jan 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Reading binary registry values using regobj.dll

2. Adding a value to the registry of a remote PC using REGOBJ.DLL

3. Newbie needs help in reading installed programs from the registry using RegObj.dll

4. Newbie needs help in reading installed programs from the registry using RegObj.dll

5. Registry access using regobj.dll on NT

6. Newbie needs help in reading installed programs from the registry using RegObj.dll

7. Newbie needs help in reading installed programs from the registry using RegObj.dll

8. Registry access using regobj.dll on NT

9. RP: Need help - reading/writing binary values using regobj.dll

10. Need help - reading/writing binary values using regobj.dll

11. RP: Need help - reading/writing binary values using regobj.dll

12. I need documentation on how to use RegObj.dll (registry manip dll)

 

 
Powered by phpBB® Forum Software