Index: src/regchext/TComRegistrar.cpp =================================================================== diff -u -N -re2054db3fa2be3652ca376a318d49dbaba8539ed -rb556d023b748dfea230575959b6513acf29fd7b3 --- src/regchext/TComRegistrar.cpp (.../TComRegistrar.cpp) (revision e2054db3fa2be3652ca376a318d49dbaba8539ed) +++ src/regchext/TComRegistrar.cpp (.../TComRegistrar.cpp) (revision b556d023b748dfea230575959b6513acf29fd7b3) @@ -25,38 +25,38 @@ DetectRegsvrPaths(); } -void TComRegistrar::RegisterNative(const wchar_t* pszPath, const wchar_t* pszDir) +bool TComRegistrar::RegisterNative(const wchar_t* pszPath, const wchar_t* pszDir) { if(!PathFileExists(pszPath)) throw std::runtime_error("File does not exist"); - Register(pszPath, pszDir, m_strNativeRegsvrPath.c_str()); + return Register(pszPath, pszDir, m_strNativeRegsvrPath.c_str()); } -void TComRegistrar::UnregisterNative(const wchar_t* pszPath, const wchar_t* pszDir) +bool TComRegistrar::UnregisterNative(const wchar_t* pszPath, const wchar_t* pszDir) { if(!PathFileExists(pszPath)) throw std::runtime_error("File does not exist"); - Unregister(pszPath, pszDir, m_strNativeRegsvrPath.c_str()); + return Unregister(pszPath, pszDir, m_strNativeRegsvrPath.c_str()); } #ifdef _WIN64 -void TComRegistrar::Register32bit(const wchar_t* pszPath, const wchar_t* pszDir) +bool TComRegistrar::Register32bit(const wchar_t* pszPath, const wchar_t* pszDir) { if(!PathFileExists(pszPath)) throw std::runtime_error("File does not exist"); - Register(pszPath, pszDir, m_str32bitRegsvr.c_str()); + return Register(pszPath, pszDir, m_str32bitRegsvr.c_str()); } -void TComRegistrar::Unregister32bit(const wchar_t* pszPath, const wchar_t* pszDir) +bool TComRegistrar::Unregister32bit(const wchar_t* pszPath, const wchar_t* pszDir) { if(!PathFileExists(pszPath)) throw std::runtime_error("File does not exist"); - Unregister(pszPath, pszDir, m_str32bitRegsvr.c_str()); + return Unregister(pszPath, pszDir, m_str32bitRegsvr.c_str()); } #endif @@ -66,31 +66,67 @@ // try with regsvr32 SHELLEXECUTEINFO sei = { 0 }; sei.cbSize = sizeof(sei); - sei.fMask = SEE_MASK_UNICODE; + sei.fMask = SEE_MASK_UNICODE | SEE_MASK_NOCLOSEPROCESS; sei.lpVerb = L"runas"; sei.lpFile = pszRegsvrPath; sei.lpDirectory = pszDir; std::wstring strParams = std::wstring(L"/s \"") + pszPath + L"\""; sei.lpParameters = strParams.c_str(); sei.nShow = SW_SHOW; - return ShellExecuteEx(&sei) != FALSE; + if (!ShellExecuteEx(&sei)) + return false; + + if (WaitForSingleObject(sei.hProcess, 10000) != WAIT_OBJECT_0) + { + CloseHandle(sei.hProcess); + return false; + } + + DWORD dwExitCode = 0; + if (!GetExitCodeProcess(sei.hProcess, &dwExitCode)) + { + CloseHandle(sei.hProcess); + return false; + } + + CloseHandle(sei.hProcess); + + return dwExitCode == 0; } bool TComRegistrar::Unregister(const wchar_t* pszPath, const wchar_t* pszDir, const wchar_t* pszRegsvrPath) { // try with regsvr32 SHELLEXECUTEINFO sei = { 0 }; sei.cbSize = sizeof(sei); - sei.fMask = SEE_MASK_UNICODE; + sei.fMask = SEE_MASK_UNICODE | SEE_MASK_NOCLOSEPROCESS; sei.lpVerb = L"runas"; sei.lpFile = pszRegsvrPath; sei.lpDirectory = pszDir; std::wstring strParams = std::wstring(L"/u /s \"") + pszPath + L"\""; sei.lpParameters = strParams.c_str(); sei.nShow = SW_SHOW; - return ShellExecuteEx(&sei) != FALSE; + if (!ShellExecuteEx(&sei)) + return false; + + if (WaitForSingleObject(sei.hProcess, 10000) != WAIT_OBJECT_0) + { + CloseHandle(sei.hProcess); + return false; + } + + DWORD dwExitCode = 0; + if (!GetExitCodeProcess(sei.hProcess, &dwExitCode)) + { + CloseHandle(sei.hProcess); + return false; + } + + CloseHandle(sei.hProcess); + + return dwExitCode == 0; } void TComRegistrar::DetectRegsvrPaths()