APanda

I believe there are compile time defines which should allow one to figure out what version of Windows code is being compiled under (basically distinguish compilation under Windows Vista from compilation under Windows XP), however I don't remember what these are, and was wondering if someone could tell me what these were


Re: Visual C++ General Defines for specific windows versions

Bruno van Dooren

Do a search for WINVER, _WIN32_WINNT and _WIN32_WINDOWS

WINVER is normally the one you set in your project options to specify the minimum windows version your project supports.

You can also use WINVER in your code files to detect which version the code is compiled for.





Re: Visual C++ General Defines for specific windows versions

Sdi

Note that, as Bruno says, these constants have nothing to do with "what version of Windows code is being compiled under"; they control what version of Windows the compiled code will target. Which may be what you want, but you'll need to clarify exactly what you're trying to find out.



Re: Visual C++ General Defines for specific windows versions

APanda

The target, pretty much. It is mostly so I can lazily avoid finding the MOF class for some of the kernel events before actually figuring out what's inside them.




Re: Visual C++ General Defines for specific windows versions

crescens2k

This type of thing is actually pretty pointless. Yes, you compile your program under Vista, doesn't stop you running it on XP. You will have to check at run time what version of Windows your program is running on, that is the only real way of doing this. The GetVersion/GetVersionEx function is what you want to do to check this.




Re: Visual C++ General Defines for specific windows versions

Simple Samples

I don't understand the relevance of the MOF class; if it relevant, then your question requires clarification. If it is not relevant, then the MOF class is irrelevant.

A #define gets evaluated by the preprocessor and does not exist after the preprocessor, therefore it is useless during execution. So perhaps GetVersionEx is what you need.