Because you want to determine the number of system bits to decide the different operations in the program.
The first thing to think about is whether or not there are packaged classes in Qt, and discover that the Qsysinfo class can provide us with some underlying information about the current system. In the Qsysinfo class, qsysinfo::wordsize can return the pointer size (32 or 64) for the platform on which the application is compiled. However, in the actual use process, it is found that the return of 32 or 64 is based on the compiler, if compiled into 32 bits that returns 32, 63 bits return 64.
So you can only use Windows system functions to determine the current system environment, there is a iswow64process function in the Windows system functions, you can use to determine whether the specified process runs under WOW64. However, the official state clearly stated:
To be compatible with operating systems that do not support this feature, call GetProcAddress to detect whether iswow64processis implemented in Kernel32.dll. If GetProcAddress succeeds, it is safe to call this function. Otherwise, WOW64 does not exist. Note that this technique is not a reliable way to detect whether the operating system is a 64-bit version of Windows, because Kernel32.dll in the current version of 32-bit Windows also includes this feature.
Therefore, using the GetProcAddress function, this method retrieves the address of the exported function or variable from the specified dynamic-link library (DLL). In Kernel32.dll, there is a getnativesysteminfo function that retrieves information about the current system, passes a SYSTEM_INFO structure to the modifier, The processor architecture (Wprocessorarchitecture attribute) that is included in the structure can be: processor_architecture_amd64, Processor_architecture_arm, Processor_architecture_arm64, Processor_architecture_ia64, Processor_architecture_intel, PROCESSOR_ARCHITECTURE_ Unknown one of these values, so you can determine whether the system is 64-bit based on these values.
The specific code is as follows:
1 BOOLIs64bitsystem ()2 {3typedefvoid(WINAPI *Pgnsi) (lpsystem_info);4 Pgnsi Pgnsi;5 system_info si;6ZeroMemory (&si,sizeof(System_info));7Pgnsi = (pgnsi) GetProcAddress (GetModuleHandle (TEXT ("Kernel32.dll")),"Getnativesysteminfo");8 if(Pgnsi)9 {TenPgnsi (&si); One A if(si.wprocessorarchitecture = = Processor_architecture_amd64 | | -Si.wprocessorarchitecture = = Processor_architecture_ia64 | | -Si.wprocessorarchitecture = =processor_architecture_arm64) the { - return TRUE; - } - } + return FALSE; -}
Determine the number of Windows system bits in QT