@@ -337,46 +337,71 @@ void CUIforETWDlg::CheckSymbolDLLs()
337
337
338
338
void CUIforETWDlg::GetInstallFolder ()
339
339
{
340
- // The WPT installer is always a 32-bit installer, so we look for it in
340
+ // The WPT installer is (was?) always a 32-bit installer, so we look for it in
341
341
// ProgramFilesX86 / WOW6432Node, on 32-bit and 64-bit operating systems.
342
342
wpt10Dir_ = ReadRegistryString (HKEY_LOCAL_MACHINE, L" SOFTWARE\\ Microsoft\\ Microsoft SDKs\\ Windows\\ v10.0" , L" InstallationFolder" , true );
343
343
if (!wpt10Dir_.empty ())
344
344
{
345
345
EnsureEndsWithDirSeparator (wpt10Dir_);
346
346
wpt10Dir_ += L" Windows Performance Toolkit\\ " ;
347
+ if (!PathFileExists ((wpt10Dir_ + L" xperf.exe" ).c_str ()))
348
+ wpt10Dir_.clear ();
347
349
}
348
350
349
- // Look for alternate install paths if needed.
351
+ // Some users (issue #159) reported that the registry key above doesn't work,
352
+ // and that this registry key should be used instead.
353
+ if (wpt10Dir_.empty ())
354
+ {
355
+ // Other sources suggest looking here:
356
+ // HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots
357
+ // https://stackoverflow.com/questions/35119223/how-to-programmatically-detect-and-locate-the-windows-10-sdk/35121768#35121768
358
+ wpt10Dir_ = ReadRegistryString (HKEY_LOCAL_MACHINE, L" SOFTWARE\\ WOW6432Node\\ Microsoft\\ Windows Kits\\ Installed Roots" , L" KitsRoot10" , true );
359
+ EnsureEndsWithDirSeparator (wpt10Dir_);
360
+ wpt10Dir_ += L" Windows Performance Toolkit\\ " ;
361
+ if (!PathFileExists ((wpt10Dir_ + L" xperf.exe" ).c_str ()))
362
+ wpt10Dir_.clear ();
363
+ }
364
+
365
+ // Look for alternate install paths if needed. This was needed in 2023 for
366
+ // when UIforETW installed WPT without first installing the SDK, causing WPT to
367
+ // be installed into the 64-bit program files directory, but with no
368
+ // InstallationFolder reg key. It's not clear whether KitsRoot10 resolves this.
369
+ const wchar_t * const suffix = L" \\ Windows Kits\\ 10\\ Windows Performance Toolkit\\ " ;
370
+ std::wstring windowsKits86Dir;
350
371
{
351
- const wchar_t * const suffix = L" \\ Windows Kits\\ 10\\ Windows Performance Toolkit\\ " ;
352
372
wchar_t * progFilesx86Dir = nullptr ;
353
373
if (!SUCCEEDED (SHGetKnownFolderPath (FOLDERID_ProgramFilesX86, 0 , nullptr , &progFilesx86Dir)))
354
374
std::terminate ();
355
- std::wstring windowsKits86Dir = progFilesx86Dir;
375
+ windowsKits86Dir = progFilesx86Dir;
356
376
CoTaskMemFree (progFilesx86Dir);
357
377
windowsKits86Dir += suffix;
378
+ }
358
379
380
+ std::wstring windowsKitsDir;
381
+ {
359
382
wchar_t * progFilesDir = nullptr ;
360
383
if (!SUCCEEDED (SHGetKnownFolderPath (FOLDERID_ProgramFiles, 0 , nullptr , &progFilesDir)))
361
384
std::terminate ();
362
- std::wstring windowsKitsDir = progFilesDir;
385
+ windowsKitsDir = progFilesDir;
363
386
CoTaskMemFree (progFilesDir);
364
387
windowsKitsDir += suffix;
388
+ }
365
389
366
- // If the registry entries were unavailable, fall back to assuming their installation directory.
367
- // Starting with the 22H2 SDK this is the ProgramFiles directory rather than ProgramFilesX86
368
- if (wpt10Dir_.empty ())
369
- {
390
+ // If the registry entries were unavailable, fall back to assuming their installation directory.
391
+ // Starting with the 22H2 SDK this is the ProgramFiles directory rather than ProgramFilesX86
392
+ if (wpt10Dir_.empty ())
393
+ {
394
+ wpt10Dir_ = windowsKitsDir;
395
+ }
396
+
397
+ // If xperf.exe doesn't exist in wpt10Dir_ and it does exist in one of the two
398
+ // default paths then switch to that.
399
+ if (!PathFileExists ((wpt10Dir_ + L" xperf.exe" ).c_str ()))
400
+ {
401
+ if (PathFileExists ((windowsKits86Dir + L" xperf.exe" ).c_str ()))
402
+ wpt10Dir_ = windowsKits86Dir;
403
+ else if (PathFileExists ((windowsKitsDir + L" xperf.exe" ).c_str ()))
370
404
wpt10Dir_ = windowsKitsDir;
371
- }
372
- // If xperf.exe doesn't exist in wpt10Dir_ and it does exist elsewhere, switch to that.
373
- else if (!PathFileExists ((wpt10Dir_ + L" xperf.exe" ).c_str ()))
374
- {
375
- if (PathFileExists ((windowsKits86Dir + L" xperf.exe" ).c_str ()))
376
- wpt10Dir_ = windowsKits86Dir;
377
- else if (PathFileExists ((windowsKitsDir + L" xperf.exe" ).c_str ()))
378
- wpt10Dir_ = windowsKitsDir;
379
- }
380
405
}
381
406
}
382
407
0 commit comments