怎样判断WIN7 是 32位还是 64位的?

Amaza 2011-02-04 12:43:18
试过用program files (X86) 这个目录做判断,感觉不是很专业,有这方面的API吗?
...全文
2487 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
无·法 2011-06-17
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 xtdumpling 的回复:]

batch
systeminfo.exe /FO LIST | find /I "x86-based PC"
systeminfo.exe /FO LIST | find /I "x64-based PC"

vbs
VB code

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmg……
[/Quote]不错
xtdumpling 2011-06-17
  • 打赏
  • 举报
回复
batch
systeminfo.exe /FO LIST | find /I "x86-based PC"
systeminfo.exe /FO LIST | find /I "x64-based PC"

vbs

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)

For Each objItem in colItems
WScript.Echo objItem.CreationClassName
Next
东方之珠 2011-05-31
  • 打赏
  • 举报
回复
我把14楼的识别32位和64位操作系统的相关代码提了出来:

Option Explicit

Private Declare Function GetModuleHandle _
Lib "kernel32" _
Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function LoadLibraryEx _
Lib "kernel32" _
Alias "LoadLibraryExA" (ByVal lpLibFileName As String, _
ByVal hFile As Long, _
ByVal dwFlags As Long) As Long
Private Declare Function GetProcAddress _
Lib "kernel32" (ByVal hModule As Long, _
ByVal lpProcName As String) As Long
Private Declare Function FreeLibrary _
Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Const DONT_RESOLVE_DLL_REFERENCES As Long = &H1
Private Type SYSTEM_INFO
wProcessorArchitecture As Integer
wReserved As Integer
dwPageSize As Long
lpMinimumApplicationAddress As Long
lpMaximumApplicationAddress As Long
dwActiveProcessorMask As Long
dwNumberOfProcessors As Long
dwProcessorType As Long
dwAllocationGranularity As Long
wProcessorLevel As Integer
wProcessorRevision As Integer
End Type

Private Declare Sub GetNativeSystemInfo _
Lib "kernel32.dll" (ByRef lpSystemInfo As SYSTEM_INFO)

Private Const PROCESSOR_ARCHITECTURE_AMD64 As Long = &H9

Private Function APIFunctionPresent(ByVal FunctionName As String, ByVal DLLName As String) As Boolean

Dim lHandle As Long
Dim lAddr As Long
Dim FreeLib As Boolean

FreeLib = False

lHandle = GetModuleHandle(DLLName)

If lHandle = 0 Then
lHandle = LoadLibraryEx(DLLName, 0&, DONT_RESOLVE_DLL_REFERENCES)
FreeLib = True
End If

If lHandle <> 0 Then
lAddr = GetProcAddress(lHandle, FunctionName)

If FreeLib Then
FreeLibrary lHandle
End If
End If

APIFunctionPresent = (lAddr <> 0)

End Function

Private Function InfoVersion64bit() As String

Dim lngRet As Long
Dim strTemp As String
Dim Si As SYSTEM_INFO

'blnIsWin64bit = False
' If APIFunctionPresent("IsWow64Process", "kernel32") Then
' IsWow64Process GetCurrentProcess, lngRet
'
' If lngRet <> 0 Then
If APIFunctionPresent("GetNativeSystemInfo", "kernel32") Then 'N'existe qu'?partir d'XP => v閞if au cas o?2000 demande
GetNativeSystemInfo Si
If Si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 Then
strTemp = "Windows for 64bits"
'blnIsWin64bit = True
Else
strTemp = "Windows for 32bits"
'blnIsWin64bit = False
End If
End If

InfoVersion64bit = strTemp

End Function



Private Sub Form_Load()
MsgBox (InfoVersion64bit)
End Sub
silencenet 2011-05-30
  • 打赏
  • 举报
回复
To:12楼
最新出炉...VB6判断进程是否是64位.[WIN7 X64下测试通过.]
http://blog.csdn.net/SilenceNet/archive/2011/05/30/6455748.aspx
-_- E文我翻译了好一会,没看太明白的,
返回值也只能说明成功返回非零值呀..
我刚特意到32位的XP试了下
IsWow64Process在正常情况下是返回非零值的
...
改天再写VB6判断X64系统的.GetNativeSystemInfo
东方之珠 2011-05-30
  • 打赏
  • 举报
回复
Windows 7 有32和64位两种版本,如果是正版的话,只能安装一种版本.
东方之珠 2011-05-30
  • 打赏
  • 举报
回复
取得岂今为止最全面的Windows版本和IE版本以及32位和64位操作系统信息
http://blog.csdn.net/chenjl1031/archive/2011/04/13/6320254.aspx
VISLIVE 2011-05-29
  • 打赏
  • 举报
回复
12楼的内容是回复11楼的朋友的:-)
VISLIVE 2011-05-29
  • 打赏
  • 举报
回复
以下是MSDN的解释:
IsWow64Process Function




Determines whether the specified process is running under WOW64.

Syntax




Copy


BOOL WINAPI IsWow64Process(
__in HANDLE hProcess,
__out PBOOL Wow64Process
);

Parameters
hProcess [in]
A handle to the process. The handle must have the PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION access right. For more information, see Process Security and Access Rights.


Windows Server 2003 and Windows XP: The handle must have the PROCESS_QUERY_INFORMATION access right.
Wow64Process [out]
A pointer to a value that is set to TRUE if the process is running under WOW64. If the process is running under 32-bit Windows, the value is set to FALSE. If the process is a 64-bit application running under 64-bit Windows, the value is also set to FALSE.

Return Value

If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.
silencenet 2011-05-29
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 vislive 的回复:]
Option Explicit
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function IsWow64Process Lib "kernel32" (ByVal hProcess As Long, ByRef Wow64Process As Long) As Lo……
[/Quote]
这份代码貌似是用来判断当前进程是否是64位的.最后判断貌似也反了了-_-!
http://blog.csdn.net/SilenceNet/archive/2010/12/19/6085576.aspx
VISLIVE 2011-05-27
  • 打赏
  • 举报
回复
Option Explicit
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function IsWow64Process Lib "kernel32" (ByVal hProcess As Long, ByRef Wow64Process As Long) As Long

Private Sub Command1_Click()
Dim lngReturn As Long
Call IsWow64Process(GetCurrentProcess, lngReturn)
If lngReturn = 0 Then
MsgBox "非64位OS"
Else
MsgBox "64位OS"
End If
End Sub
silencenet 2011-05-21
  • 打赏
  • 举报
回复
GetNativeSystemInfo可以取,不过没VB的代码,那结构还麻烦
另外估计是有个简单的方法,
我的是64位,ntdll中导出了一个函数ZwWow64ReadVirtualMemory64
我猜想32位不可能会有这么个函数吧
所以用下面的代码应该是没问题的

Dim hMod as Long
hMod=GetModuleHandle("ntdll.dll")
if GetProcAddress(hMod,"ZwWow64ReadVirtualMemory64" Then
MsgBox "64位"
else
MsgBox "32位"
end if


另C++代码使用GetNativeSystemInfo:

LPSYSTEM_INFO lpSystemInfo=new SYSTEM_INFO;
GetNativeSystemInfo(lpSystemInfo);
if (lpSystemInfo->wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)//这个地方的常数值挺多的,但我的Inter 64位是这个值
//64位
else
//32位
//-------------------------
delete lpSystemInfo;
qq545494642 2011-05-20
  • 打赏
  • 举报
回复
右键点击桌面“计算机”-“属性”查看“系统类型”,就可以看见是64位还是32位
贝隆 2011-02-06
  • 打赏
  • 举报
回复
64位的。。。。
Amaza 2011-02-04
  • 打赏
  • 举报
回复
CPU现在基本上是64位的 可很多装的是32位系统 WINVER 直接跳了个对话框出来
wo22ni 2011-02-04
  • 打赏
  • 举报
回复
在资源文件里加一个64位程序释放出来运行。如果没的返回信息或报错就是32位的。:)
clear_zero 2011-02-04
  • 打赏
  • 举报
回复
我知道64bit的注册表多了一层什么东东,具体的不记得了,可以上网查查

还有就是 run那里运行winver
这个命令可以返回很多信息

不在程序边上不知道啊
  • 打赏
  • 举报
回复
systeminfo 或注册表。
LinkSe7en 2011-02-04
  • 打赏
  • 举报
回复
应该没有 不过应该可以看CPU是32(X86)还是64(X64)的

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧