Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Detecting Windows SDK version using macros

Detecting Windows SDK version using macros

Scheduled Pinned Locked Moved C / C++ / MFC
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tareqsiraj
    wrote on last edited by
    #1

    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

    S L 2 Replies Last reply
    0
    • T tareqsiraj

      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

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • S Stuart Dootson

        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

        T Offline
        T Offline
        tareqsiraj
        wrote on last edited by
        #3

        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

        S 1 Reply Last reply
        0
        • T tareqsiraj

          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

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          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
          #endif

          and then use CONST instead of const?

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

          T 1 Reply Last reply
          0
          • S Stuart Dootson

            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
            #endif

            and then use CONST instead of const?

            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

            T Offline
            T Offline
            tareqsiraj
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • T tareqsiraj

              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

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              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

              T 1 Reply Last reply
              0
              • L Lost User

                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

                T Offline
                T Offline
                tareqsiraj
                wrote on last edited by
                #7

                ah... just what I was looking for. Thanks :).

                -Tareq

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups