@Wouter Simon 的答案有点正确,但确实不完整。它缺少一些Declare陈述以及某种解释。
因此,我认为值得在这里展示一个更完整、更有效的版本。
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 hProcess As Long, ByRef Wow64Process As Long) As Long
Sub CheckWhetherIts64()
Dim Its64 As Long
Dim handle As Long
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(), Its64
End If
If Its64 = 1 Then
MsgBox "it's a 64 bit process."
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
警告:
为了兼容不支持该功能的操作系统,请调用GetProcAddress检测Kernel32.dll中是否实现了IsWow64Process。如果 GetProcAddress 成功,则可以安全地调用此函数。否则,WOW64 不存在。请注意,此技术并不是检测操作系统是否为 64 位版本 Windows 的可靠方法,因为当前版本的 32 位 Windows 中的 Kernel32.dll 也包含此函数。
http://msdn.microsoft.com/en-us/library/ms684139%28v=vs.85%29.aspx
| 归档时间: |
|
| 查看次数: |
14894 次 |
| 最近记录: |