The following feature code determines whether to run under Windows x64. This example uses the Windows API function iswow64process, refer to the MSDN documentation:http://msdn.microsoft.com/en-us/library/ms684139 (vs.85). aspx
/*** This program test if this application are a x64 program or* is a x86 program running under Windows x64. * * version:0.1 C-lang* author:fenying* Date:2013-08-22 */#include <windows.h> #include <tchar.h> typedef BOOL (WINAPI *lpfn_iswow64process) (HANDLE, pbool );/*** Don ' t use the function iswow64process as a static function,* You should load it by function GetProcAddress, because* It is not available on all version of Windows. */lpfn_iswow64process fniswow64process = NULL; /*** This function tells if your application are a x64 program. */BOOL isx64application() { return (sizeof(lpfn_iswow64process) = = 8)? TRUE: FALSE; }/*** This function tells if you ' re under Windows x64. */BOOL IsWow64() { BOOL bIsWow64 = FALSE; if (! Fniswow64process) fniswow64process = (lpfn_iswow64process)GetProcAddress( GetModuleHandle(TEXT("kernel32")),"iswow64process"); if(fniswow64process) if (! Fniswow64process(getcurrentprocess(), &bIsWow64)) return FALSE; return bIsWow64; } int main( void ) { if (isx64application()) _tprintf(TEXT("The application is a x64 program.\n"); Else { if (! IsWow64()) _tprintf(TEXT("The application is running under Windows x86.\n"); Else _tprintf(TEXT("The application is a x86 program running under Windows x64.\n"); } return 0; }Original address: http://fenying.blog.163.com/blog/static/10205599320137224339263/
[Go] Determine if the program is running under Windows x64 system