Missing CoUninitialize (#27732)

This commit is contained in:
Anders
2023-08-03 19:44:17 +02:00
committed by GitHub
parent b54a7c3b0b
commit d4213c3e30

View File

@@ -331,20 +331,19 @@ inline bool run_non_elevated(const std::wstring& file, const std::wstring& param
inline bool RunNonElevatedEx(const std::wstring& file, const std::wstring& params, const std::wstring& working_dir) inline bool RunNonElevatedEx(const std::wstring& file, const std::wstring& params, const std::wstring& working_dir)
{ {
bool success = false;
HRESULT co_init = E_FAIL;
try try
{ {
CoInitialize(nullptr); co_init = CoInitialize(nullptr);
if (!ShellExecuteFromExplorer(file.c_str(), params.c_str(), working_dir.c_str())) success = ShellExecuteFromExplorer(file.c_str(), params.c_str(), working_dir.c_str());
{
return false;
}
} }
catch (...) catch (...)
{ {
return false;
} }
if (SUCCEEDED(co_init)) CoUninitialize();
return true; return success;
} }
struct ProcessInfo struct ProcessInfo
@@ -494,4 +493,4 @@ inline bool check_user_is_admin()
freeMemory(pSID, pGroupInfo); freeMemory(pSID, pGroupInfo);
return false; return false;
} }