检查操作系统和处理器是 32 位还是 64 位? [英] check OS and processor is 32 bit or 64 bit?
问题描述
我想要 vb6 代码来检查操作系统是 32 位还是 64 位,处理器是 32 位还是 64 位.所以请帮我获取这些代码.在 vb.net 中,我可以使用 Environment.Is64BitOperatingSystem 属性,它仅适用于 .net 4.0 及更高版本.但是如何在 vb6 中获取这些信息?
I want vb6 code to check OS is 32 bit or 64 bit and also processor is 32 bit or 64 bit.So please help me to get these codes. In vb.net i can use Environment.Is64BitOperatingSystem Property and it works only in .net 4.0 and above. But how can i get these information in vb6?
推荐答案
回答这两个问题最直接的方法似乎是使用 Win32_Processor WMI 类.
The most straightforward way to answer both questions seems to be using Win32_Processor WMI class.
对于操作系统可以检查AddressWidth
属性:
For operating system one can check AddressWidth
property:
地址宽度
在 32 位操作系统上,该值为 32,在 64 位操作系统上操作系统是64.
On a 32-bit operating system, the value is 32 and on a 64-bit operating system it is 64.
相关的VB6代码是:
Public Function GetOsBitness() As String
Dim ProcessorSet As Object
Dim CPU As Object
Set ProcessorSet = GetObject("Winmgmts:"). _
ExecQuery("SELECT * FROM Win32_Processor")
For Each CPU In ProcessorSet
GetOsBitness = CStr(CPU.AddressWidth)
Next
End Function
<小时>
处理器是 32 位还是 64 位?
对于处理器,可以检查 DataWidth
属性:
数据宽度
在 32 位处理器上,该值是 32,在 64 位处理器上它是64.
On a 32-bit processor, the value is 32 and on a 64-bit processor it is 64.
相关的VB6代码是:
Public Function GetCpuBitness() As String
Dim ProcessorSet As Object
Dim CPU As Object
Set ProcessorSet = GetObject("Winmgmts:"). _
ExecQuery("SELECT * FROM Win32_Processor")
For Each CPU In ProcessorSet
GetCpuBitness = CStr(CPU.DataWidth)
Next
End Function
这篇关于检查操作系统和处理器是 32 位还是 64 位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!