The 64-bit wnidows contains a simulator called wow64, which can enable the 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 functionsGetnativesysteminfoYou 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 providesIswow64processThe function checks whether the program runs on the wow64 simulator.
Sample Code:
Bool biswow64 = false;
Iswow64process (getcurrentprocess (), & biswow64 );
Note that the getnativesysteminfo function is available from Windows XP, And the iswow64process function is 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 ");
> OriginalArticleThe copyright belongs to the author. For more information, see the source and author information (Http://blog.csdn.net/WinGeek/), Thank you. <