[英]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.