Fixes for Explorer restart and app servicing
This commit is contained in:
+19
-12
@@ -790,18 +790,25 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
|
||||
{
|
||||
BeginExplorerRestart();
|
||||
}
|
||||
Sleep(100);
|
||||
//ZZRestartExplorer(0, 0, 0, 0);
|
||||
GetSystemDirectoryW(wszPath, MAX_PATH);
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\taskkill.exe");
|
||||
ShellExecuteW(
|
||||
NULL,
|
||||
L"open",
|
||||
wszPath,
|
||||
L"/f /im explorer.exe",
|
||||
NULL,
|
||||
SW_SHOWMINIMIZED
|
||||
);
|
||||
}
|
||||
Sleep(100);
|
||||
GetSystemDirectoryW(wszPath, MAX_PATH);
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\taskkill.exe");
|
||||
SHELLEXECUTEINFOW sei;
|
||||
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFOW));
|
||||
sei.cbSize = sizeof(sei);
|
||||
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||
sei.hwnd = NULL;
|
||||
sei.hInstApp = NULL;
|
||||
sei.lpVerb = NULL;
|
||||
sei.lpFile = wszPath;
|
||||
sei.lpParameters = L"/f /im explorer.exe";
|
||||
sei.hwnd = NULL;
|
||||
sei.nShow = SW_SHOWMINIMIZED;
|
||||
if (ShellExecuteExW(&sei) && sei.hProcess)
|
||||
{
|
||||
WaitForSingleObject(sei.hProcess, INFINITE);
|
||||
CloseHandle(sei.hProcess);
|
||||
}
|
||||
GetWindowsDirectoryW(wszPath, MAX_PATH);
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\explorer.exe");
|
||||
|
||||
@@ -588,15 +588,15 @@ HRESULT ShellExecuteFromExplorer(
|
||||
{
|
||||
HRESULT hr = E_FAIL;
|
||||
IShellFolderViewDual* spFolderView = NULL;
|
||||
hr = GetDesktopAutomationObject(&IID_IShellFolderViewDual, &spFolderView);
|
||||
GetDesktopAutomationObject(&IID_IShellFolderViewDual, &spFolderView);
|
||||
if (spFolderView)
|
||||
{
|
||||
IDispatch* spdispShell = NULL;
|
||||
hr = spFolderView->lpVtbl->get_Application(spFolderView, &spdispShell);
|
||||
spFolderView->lpVtbl->get_Application(spFolderView, &spdispShell);
|
||||
if (spdispShell)
|
||||
{
|
||||
IShellDispatch2* spdispShell2 = NULL;
|
||||
hr = spdispShell->lpVtbl->QueryInterface(spdispShell, &IID_IShellDispatch2, &spdispShell2);
|
||||
spdispShell->lpVtbl->QueryInterface(spdispShell, &IID_IShellDispatch2, &spdispShell2);
|
||||
if (spdispShell2)
|
||||
{
|
||||
BSTR a_pszFile = pszFile ? SysAllocString(pszFile): SysAllocString(L"");
|
||||
|
||||
+32
-21
@@ -455,28 +455,27 @@ int WINAPI wWinMain(
|
||||
{
|
||||
BeginExplorerRestart();
|
||||
}
|
||||
Sleep(100);
|
||||
|
||||
GetSystemDirectoryW(wszPath, MAX_PATH);
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\taskkill.exe");
|
||||
SHELLEXECUTEINFOW sei;
|
||||
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFOW));
|
||||
sei.cbSize = sizeof(sei);
|
||||
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||
sei.hwnd = NULL;
|
||||
sei.hInstApp = NULL;
|
||||
sei.lpVerb = NULL;
|
||||
sei.lpFile = wszPath;
|
||||
sei.lpParameters = L"/f /im explorer.exe";
|
||||
sei.hwnd = NULL;
|
||||
sei.nShow = SW_SHOWMINIMIZED;
|
||||
if (ShellExecuteExW(&sei) && sei.hProcess)
|
||||
{
|
||||
WaitForSingleObject(sei.hProcess, INFINITE);
|
||||
CloseHandle(sei.hProcess);
|
||||
}
|
||||
}
|
||||
}
|
||||
Sleep(100);
|
||||
GetSystemDirectoryW(wszPath, MAX_PATH);
|
||||
wcscat_s(wszPath, MAX_PATH, L"\\taskkill.exe");
|
||||
SHELLEXECUTEINFOW sei;
|
||||
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFOW));
|
||||
sei.cbSize = sizeof(sei);
|
||||
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||
sei.hwnd = NULL;
|
||||
sei.hInstApp = NULL;
|
||||
sei.lpVerb = NULL;
|
||||
sei.lpFile = wszPath;
|
||||
sei.lpParameters = L"/f /im explorer.exe";
|
||||
sei.hwnd = NULL;
|
||||
sei.nShow = SW_SHOWMINIMIZED;
|
||||
if (ShellExecuteExW(&sei) && sei.hProcess)
|
||||
{
|
||||
WaitForSingleObject(sei.hProcess, INFINITE);
|
||||
CloseHandle(sei.hProcess);
|
||||
}
|
||||
|
||||
HWND hWnd = FindWindowW(L"ExplorerPatcher_GUI_" _T(EP_CLSID), NULL);
|
||||
if (hWnd)
|
||||
@@ -720,7 +719,19 @@ int WINAPI wWinMain(
|
||||
|
||||
if (!hEvent0 || !hEvent1 || FAILED(hr))
|
||||
{
|
||||
StartExplorerWithDelay(1000);
|
||||
if (!hShellTrayWnd)
|
||||
{
|
||||
MessageBoxW(
|
||||
NULL,
|
||||
L"" _T(PRODUCT_NAME) L" has been installed successfully. Start Explorer to have it load up.",
|
||||
_T(PRODUCT_NAME),
|
||||
MB_ICONINFORMATION | MB_OK | MB_DEFBUTTON1
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartExplorerWithDelay(1000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user