1

Possible Duplicate:
How to detect Windows 64 bit platform with .net?

I am totally new to VB. I have VS2008 express edition on my machine and I want to know the bit architecture of my (target user's) machine. I got OS name and major and minor versions but how do I get bit architeture?

Community
  • 1
  • 1
user1079065
  • 2,085
  • 9
  • 30
  • 53

3 Answers3

5

I have already linked to a previously asked question on this but

The easiest solution is (if you can) is use Visual Studio 2010 onwards, then If you want to know what the bitedness is of the operating system you can simply use:

Environment.Is64BitOperatingSystem

If you want to know the bitedness of the processor then use kor_'s answer already given (although why you would need to know this I don't know)

Note:- you can also check the bitedness of the process you are running:

Environment.Is64BitProcess
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
3
Dim Is64Bit As Boolean

Is64Bit = Not String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))

See also: How to detect Windows 64-bit platform with .NET?

Community
  • 1
  • 1
kor_
  • 1,510
  • 1
  • 16
  • 36
2

If you want to know whether the OS is 32-bit or 64-bit and you're using .NET Framework 4.0 or higher, use Environment.Is64BitOperatingSystem.

If you want to know whether the current process is 32-bit or 64-bit and you're using .NET Framework 4.0 or higher, use Environment.Is64BitProcess.

I've tested these two on Windows 7 and XP SP3, but not on any earlier OS version.

If you want to know the CPU bitness, you can use this WMI call:

Dim mo = New ManagementObject("Win32_Processor.DeviceID='CPU0'")
Dim i As UShort = CUShort(mo("Architecture"))

Select Case i
    Case 0
        Return "32 Bit"
    Case 6  'Itanium
        Return "64-bit"
    Case 9
        Return "64-bit"
    Case Else 'Ooops!
        Exit Select    
End Select
HTTP 410
  • 17,300
  • 12
  • 76
  • 127