1,488
社区成员
发帖
与我相关
我的任务
分享
Const HKEY_LOCAL_MACHINE = &H80000002
Dim x As Long, rKey As Long, sBuf As String, ret As Long, rType As Long
'ret = RegOpenKey(HKEY_LOCAL_MACHINE, RP, rKey)
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, RP, 0, KEY_ALL_ACCESS, rKey)
If ret Then '不存在时
ret = RegCreateKeyEx(HKEY_LOCAL_MACHINE, RP, 0, "REG_DWORD", _
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0&, rKey, ByVal 0&)
If ret = 0 Then
MsgBox "打开注册表项:HKEY_LOCAL_MACHINE" & RP & "出错!", vbCritical
Exit Function
End If
End If
If Value = vbNullString Then
ret = RegDeleteValue(rKey, RN)
If ret Then MsgBox "RegDeleteValue Code:" & ret
Else
ret = RegSetValueEx(rKey, RN, 0&, 1&, Value & vbNullChar, LenB(Value))
If ret Then MsgBox "RegSetValueEx Code:" & ret
End If
RegCloseKey rKey
RegSetValue = ret = 0
If ret Then
MsgBox "RegSetValueEx Code:" & ret
End If