VB构建模块编译之后出现:没有适当的对象方法无效 代码如下请大神指点迷津,谢谢!

Option Explicit
Const ERROR_SUCCESS = 0&
Const ERROR_BADDB = 1009&
Const ERROR_BADKEY = 1010&
Const REG_EXPAND_SZ = 2&
Const REG_BINARY = 3&
Const KEY_QUERY_VALUE = &H1&
Const KEY_ENUMERATE_SUB_KEYS = &H8&
Const KEY_NOTIFY = &H10&
Const READ_CONTROL = &H20000
Const STANDARD_RIGHTS_READ = READ_CONTROL
Const KEY_READ = STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY
Const HKEY_CURRENT_USER = &H80000001
Dim hKey As Long, MainKeyHandle As Long
Dim rtn As Long, lBuffer As Long, sBuffer As String, SubKey As String
Dim lBufferSize As Long
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "Reg QueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Public Function GetBinaryValue(Entry As String)
MainKeyHandle = HKEY_CURRENT_USER
SubKey = "Control Panel\desktop\"
rtn = RegOpenKeyEx(MainKeyHandle, SubKey, 0, KEY_READ, hKey)
If rtn = ERROR_SUCCESS Then '如果HKEY_CURRENT_USER\Control Panel\desktop键被成功打开
lBufferSize = 1
rtn = RegQueryValueEx(hKey, Entry, 0, REG_BINARY, 0, lBufferSize) '读取ScreenSave_Data的值
sBuffer = Space(lBufferSize)
rtn = RegQueryValueEx(hKey, Entry, 0, REG_BINARY, sBuffer, lBufferSize)
If rtn = ERROR_SUCCESS Then Print '如果读取ScreenSave_Data的值成功
rtn = RegCloseKey(hKey)
GetBinaryValue = sBuffer '函数返回ScreenSave_Data的值
Else '如果读取ScreenSave_Data的值不成功
Call ErrorMsg
End
End If
Else: Print '如果HKEY_CURRENT_USER\Control Panel\desktop键不能打开
Call ErrorMsg '调用ErrorMsg()过程
End
End If
End Function
Private Sub ErrorMsg() '显示错误信息过程
Select Case rtn
Case ERROR_BADDB
MsgBox ("您的计算机注册表有错误!")
Case ERROR_BADKEY, REG_EXPAND_SZ
MsgBox ("您的计算机未设屏保密码!")
Case Else
MsgBox ("破解过程中遇到未知错误,错误号:" & Str$(rtn))
End Select
End Sub

主要的问题是:
你在全程函数GetBinaryValue(Entry As String) 中使用了 Print语句没有指明其对象,就是说:你的输出结果在什么地方呈现?可以选择 Debug.Pring 或者某个 Form.Print....最直接的办法 就是修改为 MsgBox提示窗.
MsgBox "读取ScreenSave_Data的值成功!"
温馨提示:内容为网友见解,仅供参考
无其他回答

Warning: Invalid argument supplied for foreach() in /www/wwwroot/aolonic.com/skin/templets/default/contents.html on line 45
相似回答