VB如何在注册表中添加项
来源:百度知道 编辑:UC知道 时间:2024/05/17 22:39:36
为什么我用RegCreateKey函数创建项总是返回87的失败值?代码如下:
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal phkResult As Long) As Long
Const HKEY_CURRENT_USER = &H80000001
Private Sub Command1_Click()
Dim name As Long
Dim record As Long
record = RegCreateKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System\kami",name)
print record
End Sub
抄袭、复制代码的无效,我就想知道原因及改正方法
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal phkResult As Long) As Long
Const HKEY_CURRENT_USER = &H80000001
Private Sub Command1_Click()
Dim name As Long
Dim record As Long
record = RegCreateKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System\kami",name)
print record
End Sub
抄袭、复制代码的无效,我就想知道原因及改正方法
用
Set w = CreateObject("wscript.shell")
w.regwrite "HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System\kami,name"
不就更简单?(仅需要两行代码)
在
(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System\kami",name)
中
改成
("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\kami,name")
再一次帖出这个注册表操作通用函数 如果楼主用到就用 用不到就算了~~~
我已经怕了RegQueryValue了
'==================================================
'注册表操作声明
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 RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal