mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[PT Run] Retry on unavailable desktop (#17864)
* retry on unavailable desktop * improved code
This commit is contained in:
committed by
GitHub
parent
2a7afa38d0
commit
0549b02315
@@ -83,9 +83,25 @@ namespace
|
|||||||
inline bool GetDesktopAutomationObject(REFIID riid, void** ppv)
|
inline bool GetDesktopAutomationObject(REFIID riid, void** ppv)
|
||||||
{
|
{
|
||||||
CComPtr<IShellView> spsv;
|
CComPtr<IShellView> spsv;
|
||||||
if (!FindDesktopFolderView(IID_PPV_ARGS(&spsv)))
|
|
||||||
|
// Desktop may not be available on startup
|
||||||
|
auto attempts = 5;
|
||||||
|
for (auto i = 1; i <= attempts; i++)
|
||||||
{
|
{
|
||||||
return false;
|
if (FindDesktopFolderView(IID_PPV_ARGS(&spsv)))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::warn(L"FindDesktopFolderView() failed attempt {}", i);
|
||||||
|
|
||||||
|
if (i == attempts)
|
||||||
|
{
|
||||||
|
Logger::warn(L"FindDesktopFolderView() max attempts reached");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sleep(3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
CComPtr<IDispatch> spdispView;
|
CComPtr<IDispatch> spdispView;
|
||||||
|
|||||||
Reference in New Issue
Block a user