不好意思,刚的贴结的太快,还有一点小问题,请帮忙

weiyulin 2006-10-21 10:36:39
Option Explicit

Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String) As Long
Public Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal Hkey As Long, ByVal lpValueName As String) As Long
Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Public Const REG_SZ = 2 '2类型为 [多字符值]
Public Const REG_DWORD = 4
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HKEY_PERFORMANCE_DATA = &H80000004
Public Const ERROR_SUCCESS = 0&

Public Sub Savestring(Hkey As Long, strPath As String, strValue As String, ByVal strdata As String)

'函数说明: 添加注册表值
'函数返回: 无
'函数开发: CNS(魏玉霖)

Dim keyhand As Long

Dim r As Long
r = RegCreateKey(Hkey, strPath, keyhand)
r = RegSetValueEx(keyhand, strValue, 0, REG_DWORD, ByVal strdata, 4)
r = RegCloseKey(keyhand)

End Sub
'以上为访问系统注册表



Call Savestring(HKEY_LOCAL_MACHINE, "System\CurrentControlSet\Control\CrashControl", "AutoReboot", 0)
用以上代码写注册表,值为0,但在注册表中看到AutoReboot的值不是0,还是48


不解。。。。 在线等。。。。
...全文
105 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
Hassle 2006-10-21
dim nData as long
nData=0
r = RegSetValueEx(keyhand, strValue, 0, REG_DWORD, nData, 4)
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7522

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2006-10-21 10:36
社区公告
暂无公告