• [转]判断程序是否运行在 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/
  • 相关阅读:
    过去式和过去进行式
    现在式和现在进行式
    英文文法的最基本规则
    Vue 标签中的ref属性和refs
    APICloud
    小程序
    React 传值 组件传值 之间的关系
    css clip样式 属性功能及作用
    小程序点击预览 为什么显示空白
    小程序
  • 原文地址:https://www.cnblogs.com/schowen/p/5595210.html
Copyright © 2020-2023  润新知