zoukankan      html  css  js  c++  java
  • [转]判断程序是否运行在 Windows x64 系统下

    以下功能代码判断是否运行在 Windows x64 下。本例使用 Windows API 函数 IsWow64Process,具体请参考MSDN文档:http://msdn.microsoft.com/en-us/library/ms684139(VS.85).aspx

    /**
     *   This program test if this application is 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 is 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. "));
        else {
            if (!IsWow64())
                _tprintf(TEXT("The application is running under Windows x86. "));
            else
                _tprintf(TEXT("The application is a x86 program running under Windows x64. "));
        }
     
        return 0;
    }
     
     
     
    原文地址:http://fenying.blog.163.com/blog/static/10205599320137224339263/
  • 相关阅读:
    关于javascript获取页面高度宽度
    regexp_substr在oracle9i的替换方案
    iOS-数据存储
    iOS-导入XMPP框架
    iOS-WWDC
    iOS-在Xcode中使用Git进行源码版本控制(转)
    iOS-AFN
    iOS-网络基础
    iOS-UIDynamic
    iOS-动画
  • 原文地址:https://www.cnblogs.com/schowen/p/5595210.html
Copyright © 2011-2022 走看看