0

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.

I found _WIN32 & _WIN64 macros in MSVS but it seems there is a bug in VS2008 & VS2010 they is no _WIN64 defined in them.

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() ??

Community
  • 1
  • 1
NDestiny
  • 1,133
  • 1
  • 12
  • 28
  • 3
    Note that your 32 bits application **cannot** load a 64 bits DLL. The OS is irrelevant. – MSalters Feb 27 '17 at 10:56
  • The bug was an IDE bug, not a compiler bug. When compiling, the macro is present. However, absence of `_WIN64` doesn't stop the user from running the program on a 64-bit Windows. That's where `IsWow64Process()` comes in. – Bo Persson Feb 27 '17 at 11:42
  • @MSalters I didn't say I am loading 64-bit DLL, I wanted to load different DLL of 32-bit only. – NDestiny Feb 28 '17 at 08:20
  • @Durga: Wouldn't it be easier to fix that in the installer? – MSalters Feb 28 '17 at 08:44

1 Answers1

4

You can't possible have a preprocessor macro which tells you whether you are running on 32-bit or 64-bit 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.

You will have to use a run-time function.

Note that this whole thing sounds like an X-Y problem; Microsoft goes to considerable lengths to avoid you needing to know what the OS is. I suggest asking another question with your real problem.