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