简体   繁体   English

从c / c ++应用程序确定32位操作系统还是64位操作系统

[英]determine 32-bit OS or 64-bit OS from c/c++ application

I have 32-bit application build on Microsoft visual studio, now I have to run this application on 64-bit Operating system & my requirement is based on OS (32-bit or 64-bit) I need to load a dll, I am just looking for a macro in Visual studio which tells me what the current operating system bitness (32-bit or 64-bit) on which I am running my application. 我在Microsoft Visual Studio上构建了32位应用程序,现在我必须在64位操作系统上运行此应用程序,并且我的要求基于OS(32位或64位),我需要加载dll,我是只是在Visual Studio中寻找一个宏即可告诉我正在运行我的应用程序的当前操作系统位(32位或64位)是什么。

I found _WIN32 & _WIN64 macros in MSVS but it seems there is a bug in VS2008 & VS2010 they is no _WIN64 defined in them. 我在MSVS中发现了_WIN32和_WIN64宏,但是VS2008和VS2010中似乎有一个错误 ,它们中没有定义_WIN64。

is there a way in Visual studio () that i can determine whether I am running my application on 64-bit OS or 32-bit OS (not 32-bit application or 64-bit application), to be more specific, I am looking for a macro not a function like IsWow64Process() ?? 在Visual Studio()中是否可以确定我是在64位OS还是32位OS(不是32位应用程序或64位应用程序)上运行我的应用程序,更具体地说,我在寻找对于宏不是像IsWow64Process()这样的函数?

You can't possible have a preprocessor macro which tells you whether you are running on 32-bit or 64-bit Windows. 您不可能有一个预处理器宏来告诉您是在32位还是64位Windows上运行。 The value of a preprocessor macro is defined at compile time. 预处理宏的值在编译时定义。 The same executable (compiled just once), can be run on both 32-bit and 64-bit Windows. 相同的可执行文件(仅编译一次)可以在32位和64位Windows上运行。

You will have to use a run-time function. 您将必须使用运行时功能。

Note that this whole thing sounds like an XY problem; 请注意,这听起来像是一个XY问题。 Microsoft goes to considerable lengths to avoid you needing to know what the OS is. Microsoft竭尽全力避免您需要了解什么操作系统。 I suggest asking another question with your real problem. 我建议用您的实际问题再问一个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将C ++项目从32位迁移到64位以支持MAC OS 10.14(Mojave)? - How to migrate C++ project from 32-Bit to 64-Bit to support MAC OS 10.14(Mojave)? "如何从 32 位 C++ 应用程序启动 64 位 Java 应用程序?" - How to start 64-bit Java application from 32-bit C++ application? 为什么我在 32 位 Mac OS X 系统上看到 C++ 中的 64 位指针? - Why do I see 64-bit pointers in C++ on my 32-bit Mac OS X system? 在Windows 7 64位中开发32位C ++应用程序 - Developing 32-bit C++ application in Windows 7 64-bit 从32位C#到64位C ++的PostMessage参数 - PostMessage params from 32-bit C# to 64-bit C++ C ++ Visual Studio 2008,将项目从64位迁移到32位 - C++ Visual Studio 2008, moving a project from 64-bit to 32-bit 从源代码在64位计算机上构建32位mysql c ++连接器 - Building 32-bit mysql c++ connector from source on a 64-bit machine 我可以依靠“ sizeof”来确定我使用的是32位操作系统还是64位操作系统 - Can I rely on 'sizeof' in order to determine whether I'm using 32-bit OS or 64-bit OS 在32位OS下查询中的垃圾字符,在64位上很好 - Garbage character from query under 32-bit OS, fine in 64-bit 32位OS中的16位和64位OS中的32位是什么数据类型? - What data type is 16 bits in 32-bit OS and 32bits in 64-bit OS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM