|
-
August 29th, 2001, 04:35 AM
#1
Setting Registry Value
Hi All,
I'm trying to set a DWORD value in the Win2k System Registry using RegSetValueExA. But it is giving an Error 998.
Can anyone tell me what am I doing wrong?
Here's the function call :
dim setval as long
setval = 10
RegFuncRetval = RegSetValueExA _
(phk, _
"Status_Code", 0&, REG_DWORD, _
setval, 4)
Here phk has been obtained from an earlier call to RegOpenKeyExA
Please help.
Thanks.
-
August 29th, 2001, 05:13 AM
#2
Re: Setting Registry Value
what's your API declaration?
hi,brt
<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
</center>
-
August 29th, 2001, 05:15 AM
#3
Re: Setting Registry Value
Public Declare Function RegSetValueExA Lib "advapi32.dll" _
(ByVal hKey As Long, ByVal lpValueName As _
String, ByVal Reserved As Long, ByVal dwType As Long, ByVal _
lpValue As Any, ByVal cbData As Long) As Long
-
August 29th, 2001, 05:22 AM
#4
Re: Setting Registry Value
try this:
dim strData as string
strData= "10"
RegFuncRetval = RegSetValueExA _
(phk, _
"Status_Code", 0&, REG_DWORD, ByVal strData, LenB(StrConv(strData, vbFromUnicode)) + 1)
hi,brt
<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
</center>
-
August 29th, 2001, 06:02 AM
#5
Re: Setting Registry Value
Nope, it didn't work. Gives the same error code
i.e., 998
Regards.
-
August 29th, 2001, 06:05 AM
#6
Re: Setting Registry Value
sorry U must use REG_SZ instead of REG_DWORD..
hi,brt
<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
</center>
-
August 29th, 2001, 06:16 AM
#7
Re: Setting Registry Value
It puts the ASCII codes for the chars that make up the string. So for "10" it sets the value to
3031 in Hex .How do I work this around?
-
August 29th, 2001, 08:19 AM
#8
Re: Setting Registry Value
Sub RegWrite(RegKey As String, RegValue As Integer)
'==============================================
Dim RegEdit As Object
' Create the RegEdit Object
Set RegEdit = CreateObject("WScript.Shell")
' Set The Value
RegEdit.RegWrite RegKey, RegValue, "REG_DWORD"
Set RegEdit = Nothing
End Sub
This will enter the DWORD value to the registry
Iouri Boutchkine
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|