Detecting Windows SDK version using macros
-
Hi there, I was wondering if there is any standard way to detect which version of Windows SDK is installed using macros. SDK 6.1 defines some function signatures a bit differently than the Platform SDK that ships with VC++ 2005. If there is such a trick, I was thinking of using the new function signature for the newer SDKs while still letting the the people without the windows sdk 6.1 compile. Or, is there a better way to handle this situation? Thanks in advance.
-- Regards, - Tareq
-
Hi there, I was wondering if there is any standard way to detect which version of Windows SDK is installed using macros. SDK 6.1 defines some function signatures a bit differently than the Platform SDK that ships with VC++ 2005. If there is such a trick, I was thinking of using the new function signature for the newer SDKs while still letting the the people without the windows sdk 6.1 compile. Or, is there a better way to handle this situation? Thanks in advance.
-- Regards, - Tareq
tareqsiraj wrote:
SDK 6.1 defines some function signatures a bit differently than the Platform SDK that ships with VC++ 2005
You mean the extra bits on parameters, like in this definition of
CoInitializeEx
?WINOLEAPI CoInitializeEx(__in_opt LPVOID pvReserved, __in DWORD dwCoInit);
They don't make any difference to the compiler - they're just macros that expand to nothing unless you're using Prefast[^]. Just #include things and don't worry about them.
tareqsiraj wrote:
If there is such a trick, I was thinking of using the new function signature for the newer SDKs while still letting the the people without the windows sdk 6.1 compile
Not entirely sure what you mean there - as I said, just use the SDK headers and don't worry about what version they are unless they're too old for the version of Windows you're targeting and don't contain the functions you need.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
tareqsiraj wrote:
SDK 6.1 defines some function signatures a bit differently than the Platform SDK that ships with VC++ 2005
You mean the extra bits on parameters, like in this definition of
CoInitializeEx
?WINOLEAPI CoInitializeEx(__in_opt LPVOID pvReserved, __in DWORD dwCoInit);
They don't make any difference to the compiler - they're just macros that expand to nothing unless you're using Prefast[^]. Just #include things and don't worry about them.
tareqsiraj wrote:
If there is such a trick, I was thinking of using the new function signature for the newer SDKs while still letting the the people without the windows sdk 6.1 compile
Not entirely sure what you mean there - as I said, just use the SDK headers and don't worry about what version they are unless they're too old for the version of Windows you're targeting and don't contain the functions you need.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
Umm... thats not what I meant. For example, the dbghelp.h that ships with VS2005's PSDK uses PSTR for the first param of PENUMLOADED_MODULES_CALLBACK64 while the dbghelp.h that ships with SDK6.1 uses PCSTR. Now, I want both who does and doesn't have SDK6.1 to be able to compile the app. Hopefully this makes things a bit clear.
-- Regards, -Tareq
-
Umm... thats not what I meant. For example, the dbghelp.h that ships with VS2005's PSDK uses PSTR for the first param of PENUMLOADED_MODULES_CALLBACK64 while the dbghelp.h that ships with SDK6.1 uses PCSTR. Now, I want both who does and doesn't have SDK6.1 to be able to compile the app. Hopefully this makes things a bit clear.
-- Regards, -Tareq
Ah, right - hadn't noticed that before. Not quite as obvious as all the
__in
things on function parameters :-) Now, looking at the SDK headers (v6.0A), they use the macro CONST to add const-ness to SDK parameter specs. So, you could do something like:#include <Windows.h>
#ifndef CONST
#define CONST
#endifand then use
CONST
instead ofconst
?Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
Ah, right - hadn't noticed that before. Not quite as obvious as all the
__in
things on function parameters :-) Now, looking at the SDK headers (v6.0A), they use the macro CONST to add const-ness to SDK parameter specs. So, you could do something like:#include <Windows.h>
#ifndef CONST
#define CONST
#endifand then use
CONST
instead ofconst
?Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
Thanks for spending some time on this... unfortunately, the PSDK that comes with VC++2005 does the same with CONST. So it will have the same effect regardless of SDK6.0+.
-Tareq
-
Hi there, I was wondering if there is any standard way to detect which version of Windows SDK is installed using macros. SDK 6.1 defines some function signatures a bit differently than the Platform SDK that ships with VC++ 2005. If there is such a trick, I was thinking of using the new function signature for the newer SDKs while still letting the the people without the windows sdk 6.1 compile. Or, is there a better way to handle this situation? Thanks in advance.
-- Regards, - Tareq
Hello, I use the following to detect the version of Platform SDK/Windows SDK.
#include "ntverp.h" #if !defined(VER_PRODUCTBUILD) || VER_PRODUCTBUILD < 3790 #pragma message ("********************************************" #pragma message ("Error: You need the latest Microsoft Platform SDK to compile this project.") #pragma message ("********************************************" #endif
There are other constants defined in the header which may be of use to you. I believe my preprocessor directives above simply check that VER_PRODUCTBUILD is at minimum Platform SDK for Microsoft Windows Server 2003. There is another constant VER_PRODUCTBUILD_QFE which I *think* can determine patches and service packs. Best Wishes, -David Delaune
-
Hello, I use the following to detect the version of Platform SDK/Windows SDK.
#include "ntverp.h" #if !defined(VER_PRODUCTBUILD) || VER_PRODUCTBUILD < 3790 #pragma message ("********************************************" #pragma message ("Error: You need the latest Microsoft Platform SDK to compile this project.") #pragma message ("********************************************" #endif
There are other constants defined in the header which may be of use to you. I believe my preprocessor directives above simply check that VER_PRODUCTBUILD is at minimum Platform SDK for Microsoft Windows Server 2003. There is another constant VER_PRODUCTBUILD_QFE which I *think* can determine patches and service packs. Best Wishes, -David Delaune
ah... just what I was looking for. Thanks :).
-Tareq