Skip to content

Commit

Permalink
Fixed automatic updates; improved setup
Browse files Browse the repository at this point in the history
  • Loading branch information
valinet committed Nov 14, 2021
1 parent 140866e commit bcc1bca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
18 changes: 11 additions & 7 deletions ExplorerPatcher/updates.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ BOOL IsUpdateAvailableHelper(char* url, char* szCheckAgainst, DWORD dwUpdateTime
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,
NULL,
INTERNET_FLAG_ASYNC
0 //INTERNET_FLAG_ASYNC
))
{
InternetSetOptionA(hInternet, INTERNET_OPTION_CONNECT_TIMEOUT, &dwUpdateTimeout, sizeof(DWORD));
if (InternetSetStatusCallbackA(hInternet, IsUpdateAvailableHelperCallback) != INTERNET_INVALID_STATUS_CALLBACK)
//InternetSetOptionA(hInternet, INTERNET_OPTION_CONNECT_TIMEOUT, &dwUpdateTimeout, sizeof(DWORD));
//if (InternetSetStatusCallbackA(hInternet, IsUpdateAvailableHelperCallback) != INTERNET_INVALID_STATUS_CALLBACK)
{
HINTERNET hConnect = InternetOpenUrlA(
hInternet,
Expand All @@ -87,16 +87,17 @@ BOOL IsUpdateAvailableHelper(char* url, char* szCheckAgainst, DWORD dwUpdateTime
INTERNET_FLAG_RESYNCHRONIZE |
INTERNET_FLAG_NO_COOKIES |
INTERNET_FLAG_NO_UI |
INTERNET_FLAG_NO_CACHE_WRITE,
INTERNET_FLAG_NO_CACHE_WRITE |
INTERNET_FLAG_DONT_CACHE,
&params
);
if (!hConnect && GetLastError() == ERROR_IO_PENDING)
/*if (!hConnect && GetLastError() == ERROR_IO_PENDING)
{
if (WaitForSingleObject(params.hEvent, dwUpdateTimeout) == WAIT_OBJECT_0)
{
hConnect = params.hInternet;
}
}
}*/
if (hConnect)
{
if (szCheckAgainst)
Expand All @@ -122,14 +123,17 @@ BOOL IsUpdateAvailableHelper(char* url, char* szCheckAgainst, DWORD dwUpdateTime
}
else
{
#ifdef UPDATES_VERBOSE_OUTPUT
printf("[Updates] Failed. Read %d bytes.\n");
#endif
if (lpFail) *lpFail = TRUE;
}
}
else
{
WCHAR wszPath[MAX_PATH];
ZeroMemory(wszPath, MAX_PATH * sizeof(WCHAR));
SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszPath);
SHGetFolderPathW(NULL, SPECIAL_FOLDER_LEGACY, NULL, SHGFP_TYPE_CURRENT, wszPath);
wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH));
BOOL bRet = CreateDirectoryW(wszPath, NULL);
if (bRet || (!bRet && GetLastError() == ERROR_ALREADY_EXISTS))
Expand Down
11 changes: 9 additions & 2 deletions ep_setup/ep_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,18 @@ int WINAPI wWinMain(
//ZZRestartExplorer(0, 0, 0, 0);
}
}
if (!bOk && !(argc >= 1 && !_wcsicmp(wargv[0], L"/update_silent")))
if (!bOk) // && !(argc >= 1 && !_wcsicmp(wargv[0], L"/update_silent"))
{
MessageBoxW(
NULL,
L"An error has occured when attempting to service the product. Please reboot the computer and try again.",
L"An error has occured while servicing this product.\n"
L"Most likely, this is caused by one or more of the backup files still being in use (from"
L"a previous update). Unlocking the files will most likely fix this issue.\n\n"
L"Troubleshooting steps:\n"
L"* Close and reopen the \"Properties\" dialog, if you have it currently open.\n"
L"* Kill and restart all \"explorer.exe\" processes.\n"
L"* If you have registered this as shell extension, restarting the computer will probably fix this.\n"
L"* After everything else, reboot the computer and try again.",
_T(PRODUCT_NAME),
MB_ICONERROR | MB_OK | MB_DEFBUTTON1
);
Expand Down

0 comments on commit bcc1bca

Please sign in to comment.