TL;DR
Is there a Windows registry key (or other easily-programmable way) to find & detect the Windows SDK, which works for SDK V10.0?
I am doing something similar to this, i.e. making use of some of the tooling accompanying the Windows 10 SDK.
I am looking for a programatic way to detect and locate the Windows SDK. This technique must work for (at least) version 10.0 (current as of this question). Preferably, I would like a technique that works for all versions (and world peace would be nice too).
Previous versions (at least up to V8.1A - as was included with Visual Studio 2013) were detectable via the windows registry. (Although V<7.0 may not have been).
For 64-bit installations:
HKEY_LOCAL_MACHINE\SOFTWARE\
Wow6432Node\Microsoft\Microsoft SDKs\Windows
(note the bolded difference from 32-bit).
While for 32-bit installs:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows
, and HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SDKs\Windows
(More on that at the MSDN Windows SDK blog).
However, V10.0 (or V10.0A as is included with Visual Studio 2015) does not make a registry key as did previous versions!
There are techniques using compiler macros to detect the SDK version. However, these are not practical simply for SDK tool use (xsd.exe, etc), as they would require an entire compilation step - AND this would not necessarily yield a path to the SDK's tool directory!
Ideally, this should be achievable using PowerShell or a batch script or some other simple means that can be included in a build script or other automated environment (they are programming tools after all).
Note:
Yes there are ways to do this by interrogating the file-system, (i.e. programmatically listing subdirectories of %ProgramFiles(x86)%\Microsoft SDKs\Windows\
, parsing out the 'V' and 'A'-s and selecting the max()
of the numbers listed (10.0, etc)...
HOWEVER, these approaches have a number of drawbacks:
- Quite clunky (filesystem access, string parsing, etc)
- Error prone, an empty folder leftover from an incorrectly uninstalled SDK could brake said clunky directory parsing.
- Subject to path differences, by platform (i.e.
%ProgramFiles(x86)%
on x64, but%ProgramFiles%
on 32-bit), and by SDK version; SDK<7 locates tooling inside aBin
directory, while SDK>7 usesbin\NETFX X.X tools
(note the lowercase 'b', just for added inconsistency). - Also subject to user installation choices ("clever" sys admin installed the SDK in C:\Stuff\WinSDK\V10.0\, for example).
Hence it would be MUCH better to achieve this programmatically, such as via the registry (as is possible for previous Windows SDK versions)
This question is not a duplicate of this one, as this question is both asking about a different SDK version, and is also asking about a programmatic (i.e. registry, etc) way to find the SDK path.
Nor is it a duplicate of this, as that question was dealing specifically with cmake and involved a build-number mismatch.