Operating system architecture
One way to get this is to use the GetNativeSystemInfo WinAPI function. It is addressed in a related issue .
The OS architecture can also be obtained through WMI if you want to achieve both goals in a similar way. On Windows Vista and newer operating systems, you can query the Win32_OperatingSystem class and analyze the OSArchitecture ( MSDN ) property. Unfortunately, this property does not exist in Windows XP and earlier versions. On these systems, you can query the Win32_ComputerSystem class and SystemType property instead ( MSDN ).
Public Function GetOsArchitecture() If IsAtLeastVista Then GetOsArchitecture = GetVistaOsArchitecture Else GetOsArchitecture = GetXpOsArchitecture End If End Function Private Function IsAtLeastVista() As Boolean IsAtLeastVista = GetOsVersion >= "6.0" End Function Private Function GetOsVersion() As String Dim OperatingSystemSet As Object Dim OS As Object Set OperatingSystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}"). _ InstancesOf("Win32_OperatingSystem") For Each OS In OperatingSystemSet GetOsVersion = Left$(Trim$(OS.Version), 3) Next End Function Private Function GetVistaOsArchitecture() As String Dim OperatingSystemSet As Object Dim OS As Object Set OperatingSystemSet = GetObject("Winmgmts:"). _ ExecQuery("SELECT * FROM Win32_OperatingSystem") For Each OS In OperatingSystemSet GetVistaOsArchitecture = Left$(Trim$(OS.OSArchitecture), 2) Next End Function Private Function GetXpOsArchitecture() As String Dim ComputerSystemSet As Object Dim Computer As Object Dim SystemType As String Set ComputerSystemSet = GetObject("Winmgmts:"). _ ExecQuery("SELECT * FROM Win32_ComputerSystem") For Each Computer In ComputerSystemSet SystemType = UCase$(Left$(Trim$(Computer.SystemType), 3)) Next GetXpOsArchitecture = IIf(SystemType = "X86", "32", "64") End Function
source share