[Go] Determine if the program is running under Windows x64 system

Source: Internet
Author: User
Tags windows x64 windows x86

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.