【发布时间】:2015-02-25 09:50:42
【问题描述】:
下面的代码检查进程是否在 WOW64 下运行。但是现在在我的下面的代码iswow64 程序中具有布尔类型的参数。但即使变量sixtyfourbit 是true 或false,if 条件总是变为假条件。为什么即使我传递了具有正确数据类型的参数也会发生这种情况。然后我将相同的参数(布尔值)作为字符串传递给iswow64_string 过程,它工作正常。但是谁能告诉我将它作为布尔值传递有什么问题以及为什么它不起作用。
Private Declare Function GetProcAddress Lib "kernel32" _
(ByVal hModule As Long, _
ByVal lpProcName As String) As Long
Private Declare Function GetModuleHandle Lib "kernel32" _
Alias "GetModuleHandleA" _
(ByVal lpModuleName As String) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" _
() As Long
Private Declare Function IsWow64Process Lib "kernel32" _
(ByVal hProc As Long, _
bWow64Process As Boolean) As Long
Private Sub Form_Load()
sixtyfourbit = Is64bit
iswow64 (sixtyfourbit)
iswow64_string (sixtyfourbit)
End Sub
Public Function Is64bit() As Boolean
Dim handle As Long, bolFunc As Boolean
' Assume initially that this is not a Wow64 process
bolFunc = False
' Now check to see if IsWow64Process function exists
handle = GetProcAddress(GetModuleHandle("kernel32"), _
"IsWow64Process")
If handle > 0 Then ' IsWow64Process function exists
' Now use the function to determine if
' we are running under Wow64
IsWow64Process GetCurrentProcess(), bolFunc
End If
Is64bit = bolFunc
End Function
Public Function iswow64(ByVal sixtyfourbit As Boolean)
If sixtyfourbit = True Then
MsgBox ("process running under wow64")
Else
MsgBox ("process not running under wow64")
End If
End Function
Public Function iswow64_string(ByVal sixtyfourbit As String)
If sixtyfourbit = True Then
MsgBox ("process running under wow64")
Else
MsgBox ("process not running under wow64")
End If
End Function
【问题讨论】: