Skip to content

Commit 4ff4b52

Browse files
authored
Merge pull request #9664 from keveleigh/improve-reg-key-lookup
Add fallback reg key in case the default one doesn't work in BuildDeployWindow
2 parents dc61de8 + f76253e commit 4ff4b52

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Assets/MRTK/Tools/BuildWindow/BuildDeployWindow.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ private enum BuildDeployTab
7777

7878
private const string WINDOWS_10_KITS_PATH_REGISTRY_PATH = @"SOFTWARE\Microsoft\Windows Kits\Installed Roots";
7979

80+
private const string WINDOWS_10_KITS_PATH_ALTERNATE_REGISTRY_PATH = @"SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots";
81+
8082
private const string WINDOWS_10_KITS_PATH_REGISTRY_KEY = "KitsRoot10";
8183

8284
private const string WINDOWS_10_KITS_PATH_POSTFIX = "Lib";
@@ -1419,11 +1421,24 @@ private void LoadWindowsSdkPaths()
14191421
// Try to detect the installation path by checking the registry.
14201422
try
14211423
{
1422-
var registryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(WINDOWS_10_KITS_PATH_REGISTRY_PATH);
1424+
var registryKey = Win32.Registry.LocalMachine.OpenSubKey(WINDOWS_10_KITS_PATH_REGISTRY_PATH);
14231425
var registryValue = registryKey.GetValue(WINDOWS_10_KITS_PATH_REGISTRY_KEY) as string;
14241426
win10KitsPath = Path.Combine(registryValue, WINDOWS_10_KITS_PATH_POSTFIX);
1427+
1428+
if (!Directory.Exists(win10KitsPath))
1429+
{
1430+
registryKey = Win32.Registry.LocalMachine.OpenSubKey(WINDOWS_10_KITS_PATH_ALTERNATE_REGISTRY_PATH);
1431+
registryValue = registryKey.GetValue(WINDOWS_10_KITS_PATH_REGISTRY_KEY) as string;
1432+
win10KitsPath = Path.Combine(registryValue, WINDOWS_10_KITS_PATH_POSTFIX);
1433+
1434+
if (!Directory.Exists(win10KitsPath))
1435+
{
1436+
Debug.LogWarning($"Could not find the Windows 10 SDK installation path via registry. Reverting to default path.");
1437+
win10KitsPath = WINDOWS_10_KITS_DEFAULT_PATH;
1438+
}
1439+
}
14251440
}
1426-
catch (System.Exception e)
1441+
catch (Exception e)
14271442
{
14281443
Debug.LogWarning($"Could not find the Windows 10 SDK installation path via registry. Reverting to default path. {e}");
14291444
win10KitsPath = WINDOWS_10_KITS_DEFAULT_PATH;

0 commit comments

Comments
 (0)