vb中如何调用API函数RegSaveKey?谢谢
以下是我试着使用的代码:PrivateDeclareFunctionRegSaveKeyLib"advapi32.dll"Alias"RegSaveKeyA"(ByVal...
以下是我试着使用的代码:
Private Declare Function RegSaveKey Lib "advapi32.dll" Alias "RegSaveKeyA" (ByVal hKey As Long, ByVal lpFile As String, pSecurityAttributes As SECURITY_ATTRIBUTES) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Sub Command1_Click()
Dim lpAttr As SECURITY_ATTRIBUTES
lpAttr.nLength = 50
lpAttr.lpSecurityDescriptor = 0
lpAttr.bInheritHandle = True '
Dim lpData(3) As String
lpcbData = 255
lpSubKey = "Software\"
lxn = RegOpenKey(&H80000001, lpSubKey, phkResult)
save = RegSaveKey(phkResult, "d:\kaka.txt",lpAttr)
If save = 0 Then
i = MsgBox(good)
End If
可是不能导出注册表信息(连文件都无法生成)。请教各位,如何使用才是正确的,而且返回值不是0,其实我是不知道SECURITY_ATTRIBUTES这个怎么设定,我在网上看到将saveregkey最后的参数设置为这个(ByVal lpSecurityAttributes As Long),然后调用时候直接填0(说是缺省安全属性值,不过说是在非nt操作系统使用,我是xp),可是生成一个空文件,返回值也不是0。。
能否帮我写出正确的代码? 展开
Private Declare Function RegSaveKey Lib "advapi32.dll" Alias "RegSaveKeyA" (ByVal hKey As Long, ByVal lpFile As String, pSecurityAttributes As SECURITY_ATTRIBUTES) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Sub Command1_Click()
Dim lpAttr As SECURITY_ATTRIBUTES
lpAttr.nLength = 50
lpAttr.lpSecurityDescriptor = 0
lpAttr.bInheritHandle = True '
Dim lpData(3) As String
lpcbData = 255
lpSubKey = "Software\"
lxn = RegOpenKey(&H80000001, lpSubKey, phkResult)
save = RegSaveKey(phkResult, "d:\kaka.txt",lpAttr)
If save = 0 Then
i = MsgBox(good)
End If
可是不能导出注册表信息(连文件都无法生成)。请教各位,如何使用才是正确的,而且返回值不是0,其实我是不知道SECURITY_ATTRIBUTES这个怎么设定,我在网上看到将saveregkey最后的参数设置为这个(ByVal lpSecurityAttributes As Long),然后调用时候直接填0(说是缺省安全属性值,不过说是在非nt操作系统使用,我是xp),可是生成一个空文件,返回值也不是0。。
能否帮我写出正确的代码? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询