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
As of now, the best way I've found is to look at how Visual Studio's dev command does it. Currently (2019) this is found in winsdk.bat
under .\Common7\Tools\vsdevcmd\core\
in your Visual Studio directory. This should help if things are changed again in the future. Even if winsdk.bat
is renamed or reorganised, hopefully similar scripts will still be included.
On my system the relevant section currently looks like this:
:GetWin10SdkDir
call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node > nul 2>&1
if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node > nul 2>&1
if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE > nul 2>&1
if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE > nul 2>&1
if errorlevel 1 exit /B 1
exit /B 0
:GetWin10SdkDirHelper
@REM `Get Windows 10 SDK installed folder`
for /F "tokens=1,2*" %%i in ('reg query "%1\Microsoft\Microsoft SDKs\Windows\v10.0" /v "InstallationFolder"') DO (
if "%%i"=="InstallationFolder" (
SET WindowsSdkDir=%%~k
)
)
@REM `get windows 10 sdk version number`
setlocal enableDelayedExpansion
@REM `Due to the SDK installer changes beginning with the 10.0.15063.0 (RS2 SDK), there is a chance that the
@REM Windows SDK installed may not have the full set of bits required for all application scenarios.
@REM We check for the existence of a file we know to be included in the "App" and "Desktop" portions
@REM of the Windows SDK, depending on the Developer Command Prompt's -app_platform configuration.
@REM If "windows.h" (UWP) or "winsdkver.h" (Desktop) are not found, the directory will be skipped as
@REM a candidate default value for [WindowsSdkDir].`
set __check_file=winsdkver.h
if /I "%VSCMD_ARG_APP_PLAT%"=="UWP" set __check_file=Windows.h
if not "%WindowsSdkDir%"=="" for /f %%i IN ('dir "%WindowsSdkDir%include\" /b /ad-h /on') DO (
@REM `Skip if Windows.h|winsdkver (based upon -app_platform configuration) is not found in %%i\um.`
if EXIST "%WindowsSdkDir%include\%%i\um\%__check_file%" (
set result=%%i
if "!result:~0,3!"=="10." (
set SDK=!result!
if "!result!"=="%VSCMD_ARG_WINSDK%" set findSDK=1
)
)
)