Judge whether the operating system is 32-bit or 64-bit

Source: Internet
Author: User

1. Determine whether the operating system is 32-bit or 64-bit.

// Method I: bool iswow64 () {// function iswow64process () is used to determine whether the specified process runs in a 64-bit operating system's 32 environment (wow64) // if the process is a 32-bit process and runs on a 64-bit operating system, the value is true; otherwise, the value is false. The details are as follows: // The 32bit program runs on a 32bit system, returns 0. // The 32bit program runs in the 64-bit system and is in wow64 mode. 1 is returned. // 64-bit program runs in 64-bit system, so it is not in wow64 mode. 0 bool biswow64 = false is returned; typedef bool (winapi * lpfn_iswow64process) (handle, pbool ); lpfn_iswow64process fniswow64process = (lpfn_iswow64process) getprocaddress (getmodulehandle (text ("Kernel32 ")), "Iswow64process"); If (null! = Fniswow64process) {fniswow64process (getcurrentprocess (), & biswow64) ;}return biswow64 ;}

// Method II: bool is64bitos () {typedef bool (winapi * lpfn_pgnsi) (lpsystem_info); extends pgnsi = (Signature) getprocaddress (getmodulehandle (_ T ("kernel32.dll ")), "getnativesysteminfo"); If (pgnsi = NULL) {return false;} bool bretval = false; system_info Si = {0}; pgnsi (& Si); If (SI. wprocessorarchitecture = processor_ubunture_amd64 | Si. wprocessorarchitecture = processor_ubunture_ia64) {bretval = true;} return bretval ;}

Judge whether the operating system is 32-bit or 64-bit

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.