How to judge 32-bit OS and 64-bit OS

Source: Internet
Author: User

There are many ways to determine whether the system is 64-bit.

For C #, WMI is a simple method. We can use the addresswidth attribute in the win32_processor class to indicate the system bit width. The addresswidth value is affected by the CPU and operating system.

The specific values are shown in the following table:

  32bit OS 64bit OS
32bit CPU Addresswidth = 32 N/
64-bit CPU Addresswidth = 32 Addresswidth = 64

You can use the following C # code to obtain the addresswidth value.
(Note that you need to add reference system. Management)

Public static string detect3264 ()
{
Connectionoptions oconn = new connectionoptions ();
System. Management. managementscope OMS = new system. Management. managementscope ("// localhost", oconn );
System. Management. objectquery oquery = new system. Management. objectquery ("select addresswidth from win32_processor ");
Managementobjectsearcher osearcher = new managementobjectsearcher (OMS, oquery );
Managementobjectcollection oreturncollection = osearcher. Get ();
String addresswidth = NULL;

Foreach (managementobject oreturn in oreturncollection)
{
Addresswidth = oreturn ["addresswidth"]. tostring ();
}

Return addresswidth;
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.