The 64-bit wnidows contains a wow64 Simulator technology, which can enable 32-bitProgramRun on 64-bit windows. When you want to execute differentCodeYou need to determine whether the operating system is 32-bit or 64-bit. Use Windows API functionsGetnativesysteminfo You can obtain this information.
Sample Code:
System_info Si;
Getnativesysteminfo (& Si );
If (Si. wprocessorarchitecture = processor_ubunture_amd64 |
Si. wprocessorarchitecture! = Processor_ubunture_ia64)
{
// 64-bit Operating System
}
Else
{
// 32-bit Operating System
}
In addition, Windows API provides Iswow64process The function checks whether the program runs on the wow64 simulator.
Sample Code:
bool biswow64 = false;
iswow64process (getcurrentprocess (), & biswow64);
It must be noted that getnativesysteminfo Functions are available from Windows XP, while Iswow64process Functions are available from Windows XP with SP2 and Windows Server 2003 with SP1. So it is best to use this functionGetprocaddress.
Typedef void (winapi * lpfn_pgnsi) (lpsystem_info );
Typedef bool (winapi * lpfn_iswow64process) (handle, pbool );
Lpfn_pgnsi pgnsi = (lpfn_pgnsi) getprocaddress (
Getmodulehandle (text ("kernel32.dll"), "getnativesysteminfo ");
Lpfn_iswow64process fniswow64process = (lpfn_iswow64process) getprocaddress (
Getmodulehandle (text ("Kernel32"), "iswow64process ");