diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c
index 06d4d0f..0fc8d28 100644
--- a/ExplorerPatcher/dllmain.c
+++ b/ExplorerPatcher/dllmain.c
@@ -240,9 +240,44 @@ DWORD CheckForUpdatesThread(LPVOID unused)
hEvents[1] = CreateEventW(NULL, FALSE, FALSE, L"EP_Ev_InstallUpdates_" _T(EP_CLSID));
if (hEvents[0] && hEvents[1])
{
+ if (bShowUpdateToast)
+ {
+ ShowUpdateSuccessNotification(hModule, notifier, notifFactory, &toast);
+
+ HKEY hKey = NULL;
+
+ RegCreateKeyExW(
+ HKEY_CURRENT_USER,
+ TEXT(REGPATH),
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_READ | KEY_WOW64_64KEY | KEY_WRITE,
+ NULL,
+ &hKey,
+ NULL
+ );
+ if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
+ {
+ hKey = NULL;
+ }
+ if (hKey)
+ {
+ bShowUpdateToast = FALSE;
+ RegSetValueExW(
+ hKey,
+ TEXT("IsUpdatePending"),
+ 0,
+ REG_DWORD,
+ &bShowUpdateToast,
+ sizeof(DWORD)
+ );
+ RegCloseKey(hKey);
+ }
+ }
if (dwUpdatePolicy != UPDATE_POLICY_MANUAL)
{
- InstallUpdatesIfAvailable(hModule, bShowUpdateToast, notifier, notifFactory, &toast, UPDATES_OP_DEFAULT, bAllocConsole, dwUpdatePolicy);
+ InstallUpdatesIfAvailable(hModule, notifier, notifFactory, &toast, UPDATES_OP_DEFAULT, bAllocConsole, dwUpdatePolicy);
}
DWORD dwRet = 0;
while (TRUE)
@@ -251,12 +286,12 @@ DWORD CheckForUpdatesThread(LPVOID unused)
{
case WAIT_OBJECT_0:
{
- InstallUpdatesIfAvailable(hModule, bShowUpdateToast, notifier, notifFactory, &toast, UPDATES_OP_CHECK, bAllocConsole, dwUpdatePolicy);
+ InstallUpdatesIfAvailable(hModule, notifier, notifFactory, &toast, UPDATES_OP_CHECK, bAllocConsole, dwUpdatePolicy);
break;
}
case WAIT_OBJECT_0 + 1:
{
- InstallUpdatesIfAvailable(hModule, bShowUpdateToast, notifier, notifFactory, &toast, UPDATES_OP_INSTALL, bAllocConsole, dwUpdatePolicy);
+ InstallUpdatesIfAvailable(hModule, notifier, notifFactory, &toast, UPDATES_OP_INSTALL, bAllocConsole, dwUpdatePolicy);
break;
}
default:
diff --git a/ExplorerPatcher/updates.c b/ExplorerPatcher/updates.c
index 4b1589b..d258c2d 100644
--- a/ExplorerPatcher/updates.c
+++ b/ExplorerPatcher/updates.c
@@ -320,7 +320,10 @@ BOOL IsUpdateAvailableHelper(
if (*toast)
{
- notifier->lpVtbl->Hide(notifier, *toast);
+ if (notifier)
+ {
+ notifier->lpVtbl->Hide(notifier, *toast);
+ }
(*toast)->lpVtbl->Release((*toast));
(*toast) = NULL;
}
@@ -636,9 +639,67 @@ BOOL UpdateProduct(
);
}
+BOOL ShowUpdateSuccessNotification(
+ HMODULE hModule,
+ __x_ABI_CWindows_CUI_CNotifications_CIToastNotifier* notifier,
+ __x_ABI_CWindows_CUI_CNotifications_CIToastNotificationFactory* notifFactory,
+ __x_ABI_CWindows_CUI_CNotifications_CIToastNotification** toast
+)
+{
+ wchar_t buf[TOAST_BUFSIZ];
+ DWORD dwLeftMost = 0;
+ DWORD dwSecondLeft = 0;
+ DWORD dwSecondRight = 0;
+ DWORD dwRightMost = 0;
+ QueryVersionInfo(hModule, VS_VERSION_INFO, &dwLeftMost, &dwSecondLeft, &dwSecondRight, &dwRightMost);
+
+ __x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL;
+ const wchar_t text[] =
+ L"\r\n"
+ L" \r\n"
+ L" \r\n"
+ L" \r\n"
+ L" \r\n"
+ L" \r\n"
+ L" \r\n"
+ L" \r\n"
+ L" \r\n";
+ swprintf_s(buf, TOAST_BUFSIZ, text, dwLeftMost, dwSecondLeft, dwSecondRight, dwRightMost);
+ String2IXMLDocument(
+ buf,
+ wcslen(buf),
+ &inputXml,
+ NULL
+ );
+ if (*toast)
+ {
+ if (notifier)
+ {
+ notifier->lpVtbl->Hide(notifier, *toast);
+ }
+ (*toast)->lpVtbl->Release((*toast));
+ (*toast) = NULL;
+ }
+ if (notifFactory)
+ {
+ notifFactory->lpVtbl->CreateToastNotification(notifFactory, inputXml, toast);
+ }
+ if ((*toast) && notifier)
+ {
+ notifier->lpVtbl->Show(notifier, *toast);
+ }
+ if (inputXml)
+ {
+ inputXml->lpVtbl->Release(inputXml);
+ }
+
+ SwitchToThread();
+}
+
BOOL InstallUpdatesIfAvailable(
HMODULE hModule,
- BOOL bIsPostUpdate,
__x_ABI_CWindows_CUI_CNotifications_CIToastNotifier* notifier,
__x_ABI_CWindows_CUI_CNotifications_CIToastNotificationFactory* notifFactory,
__x_ABI_CWindows_CUI_CNotifications_CIToastNotification** toast,
@@ -657,79 +718,6 @@ BOOL InstallUpdatesIfAvailable(
DWORD dwRightMost = 0;
QueryVersionInfo(hModule, VS_VERSION_INFO, &dwLeftMost, &dwSecondLeft, &dwSecondRight, &dwRightMost);
- if (bIsPostUpdate)
- {
- __x_ABI_CWindows_CData_CXml_CDom_CIXmlDocument* inputXml = NULL;
- const wchar_t text[] =
- L"\r\n"
- L" \r\n"
- L" \r\n"
- L" \r\n"
- L" \r\n"
- L" \r\n"
- L" \r\n"
- L" \r\n"
- L" \r\n";
- swprintf_s(buf, TOAST_BUFSIZ, text, dwLeftMost, dwSecondLeft, dwSecondRight, dwRightMost);
- String2IXMLDocument(
- buf,
- wcslen(buf),
- &inputXml,
- NULL
- );
- if (*toast)
- {
- notifier->lpVtbl->Hide(notifier, *toast);
- (*toast)->lpVtbl->Release((*toast));
- (*toast) = NULL;
- }
- notifFactory->lpVtbl->CreateToastNotification(notifFactory, inputXml, toast);
- if (*toast)
- {
- notifier->lpVtbl->Show(notifier, *toast);
- }
- if (inputXml)
- {
- inputXml->lpVtbl->Release(inputXml);
- }
-
- HKEY hKey = NULL;
- DWORD dwSize = 0;
-
- RegCreateKeyExW(
- HKEY_CURRENT_USER,
- TEXT(REGPATH),
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_READ | KEY_WOW64_64KEY | KEY_WRITE,
- NULL,
- &hKey,
- NULL
- );
- if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
- {
- hKey = NULL;
- }
- if (hKey)
- {
- dwSize = FALSE;
- RegSetValueExW(
- hKey,
- TEXT("IsUpdatePending"),
- 0,
- REG_DWORD,
- &dwSize,
- sizeof(DWORD)
- );
- RegCloseKey(hKey);
- }
-
- SwitchToThread();
- }
-
if (bAllocConsole)
{
switch (dwUpdatePolicy)
@@ -804,12 +792,18 @@ BOOL InstallUpdatesIfAvailable(
{
if (*toast)
{
- notifier->lpVtbl->Hide(notifier, *toast);
+ if (notifier)
+ {
+ notifier->lpVtbl->Hide(notifier, *toast);
+ }
(*toast)->lpVtbl->Release((*toast));
(*toast) = NULL;
}
- notifFactory->lpVtbl->CreateToastNotification(notifFactory, inputXml, toast);
- if ((*toast))
+ if (notifFactory)
+ {
+ notifFactory->lpVtbl->CreateToastNotification(notifFactory, inputXml, toast);
+ }
+ if ((*toast) && notifier)
{
notifier->lpVtbl->Show(notifier, *toast);
}
@@ -863,12 +857,18 @@ BOOL InstallUpdatesIfAvailable(
{
if (*toast)
{
- notifier->lpVtbl->Hide(notifier, *toast);
+ if (notifier)
+ {
+ notifier->lpVtbl->Hide(notifier, *toast);
+ }
(*toast)->lpVtbl->Release((*toast));
(*toast) = NULL;
}
- notifFactory->lpVtbl->CreateToastNotification(notifFactory, inputXml, toast);
- if ((*toast))
+ if (notifFactory)
+ {
+ notifFactory->lpVtbl->CreateToastNotification(notifFactory, inputXml, toast);
+ }
+ if ((*toast) && notifier)
{
notifier->lpVtbl->Show(notifier, *toast);
}
@@ -902,12 +902,18 @@ BOOL InstallUpdatesIfAvailable(
);
if (*toast)
{
- notifier->lpVtbl->Hide(notifier, *toast);
+ if (notifier)
+ {
+ notifier->lpVtbl->Hide(notifier, *toast);
+ }
(*toast)->lpVtbl->Release((*toast));
(*toast) = NULL;
}
- notifFactory->lpVtbl->CreateToastNotification(notifFactory, inputXml, toast);
- if ((*toast))
+ if (notifFactory)
+ {
+ notifFactory->lpVtbl->CreateToastNotification(notifFactory, inputXml, toast);
+ }
+ if ((*toast) && notifier)
{
notifier->lpVtbl->Show(notifier, *toast);
}
@@ -964,12 +970,18 @@ BOOL InstallUpdatesIfAvailable(
);
if (*toast)
{
- notifier->lpVtbl->Hide(notifier, *toast);
+ if (notifier)
+ {
+ notifier->lpVtbl->Hide(notifier, *toast);
+ }
(*toast)->lpVtbl->Release((*toast));
(*toast) = NULL;
}
- notifFactory->lpVtbl->CreateToastNotification(notifFactory, inputXml, toast);
- if ((*toast))
+ if (notifFactory)
+ {
+ notifFactory->lpVtbl->CreateToastNotification(notifFactory, inputXml, toast);
+ }
+ if ((*toast) && notifier)
{
notifier->lpVtbl->Show(notifier, *toast);
}
diff --git a/ExplorerPatcher/updates.h b/ExplorerPatcher/updates.h
index f727a16..a226079 100644
--- a/ExplorerPatcher/updates.h
+++ b/ExplorerPatcher/updates.h
@@ -37,9 +37,14 @@ typedef struct IsUpdateAvailableParameters
};
BOOL IsUpdatePolicy(LPCWSTR wszDataStore, DWORD dwUpdatePolicy);
+BOOL ShowUpdateSuccessNotification(
+ HMODULE hModule,
+ __x_ABI_CWindows_CUI_CNotifications_CIToastNotifier* notifier,
+ __x_ABI_CWindows_CUI_CNotifications_CIToastNotificationFactory* notifFactory,
+ __x_ABI_CWindows_CUI_CNotifications_CIToastNotification** toast
+);
BOOL InstallUpdatesIfAvailable(
HMODULE hModule,
- BOOL bIsPostUpdate,
__x_ABI_CWindows_CUI_CNotifications_CIToastNotifier* notifier,
__x_ABI_CWindows_CUI_CNotifications_CIToastNotificationFactory* notifFactory,
__x_ABI_CWindows_CUI_CNotifications_CIToastNotification** toast,