From 29f7e00586412163a20e298fbf84505f8a917425 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 3 May 2022 15:30:50 -0500 Subject: Only block shutdown during Apply. --- src/test/burn/TestBA/TestBA.cs | 9 ---- .../Manual/BafThmutilTesting/BafThmUtilTesting.cpp | 52 ++++++++++++++++++++++ src/test/burn/TestData/Manual/BundleA/BundleA.wxs | 7 ++- .../burn/TestData/Manual/PackageA/PackageA.wixproj | 4 ++ .../burn/TestData/Manual/PackageA/ProductA.wxs | 15 +++++++ 5 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 src/test/burn/TestData/Manual/PackageA/ProductA.wxs (limited to 'src/test') diff --git a/src/test/burn/TestBA/TestBA.cs b/src/test/burn/TestBA/TestBA.cs index b4d74341..5f492efd 100644 --- a/src/test/burn/TestBA/TestBA.cs +++ b/src/test/burn/TestBA/TestBA.cs @@ -531,15 +531,6 @@ namespace WixToolset.Test.BA this.ShutdownUiThread(); } - protected override void OnSystemShutdown(SystemShutdownEventArgs args) - { - // Always prevent shutdown. - this.Log("Disallowed system request to shut down the bootstrapper application."); - args.Cancel = true; - - this.ShutdownUiThread(); - } - protected override void OnUnregisterBegin(UnregisterBeginEventArgs args) { if (this.forceKeepRegistration && args.RegistrationType == RegistrationType.None) diff --git a/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp b/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp index 7c533fea..3cf994fc 100644 --- a/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp +++ b/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp @@ -88,6 +88,56 @@ public: // IBAFunctions return hr; } + virtual STDMETHODIMP WndProc( + __in HWND hWnd, + __in UINT uMsg, + __in WPARAM /*wParam*/, + __in LPARAM lParam, + __inout BOOL* pfProcessed, + __inout LRESULT* plResult + ) + { + switch (uMsg) + { + case WM_QUERYENDSESSION: + if (BOOTSTRAPPER_DISPLAY_FULL <= m_command.display) + { + DWORD dwEndSession = static_cast(lParam); + if (ENDSESSION_CRITICAL & dwEndSession) + { + // Return false to get the WM_ENDSESSION message so that critical shutdowns can be delayed. + *plResult = FALSE; + *pfProcessed = TRUE; + } + } + break; + case WM_ENDSESSION: + if (BOOTSTRAPPER_DISPLAY_FULL <= m_command.display) + { + ::MessageBoxW(hWnd, L"WM_ENDSESSION", L"BAFunctions WndProc", MB_OK); + } + break; + } + return S_OK; + } + +public: //IBootstrapperApplication + virtual STDMETHODIMP OnExecuteBegin( + __in DWORD /*cExecutingPackages*/, + __inout BOOL* pfCancel + ) + { + if (BOOTSTRAPPER_DISPLAY_FULL <= m_command.display) + { + if (IDCANCEL == ::MessageBoxW(m_hwndParent, L"Shutdown requests should be denied right now.", L"OnExecuteBegin", MB_OKCANCEL)) + { + *pfCancel = TRUE; + } + } + + return S_OK; + } + private: HRESULT OnShowTheme() { @@ -138,6 +188,8 @@ private: ThemeInitializeWindowClass(m_pBafTheme, &wc, CBafThmUtilTesting::TestingWndProc, m_hModule, BAFTHMUTILTESTING_WINDOW_CLASS); + Assert(wc.lpszClassName); + // If the theme did not provide an icon, try using the icon from the bundle engine. if (!wc.hIcon) { diff --git a/src/test/burn/TestData/Manual/BundleA/BundleA.wxs b/src/test/burn/TestData/Manual/BundleA/BundleA.wxs index 20706b6a..44abc645 100644 --- a/src/test/burn/TestData/Manual/BundleA/BundleA.wxs +++ b/src/test/burn/TestData/Manual/BundleA/BundleA.wxs @@ -1,4 +1,4 @@ - + @@ -8,7 +8,10 @@ - + + + + diff --git a/src/test/burn/TestData/Manual/PackageA/PackageA.wixproj b/src/test/burn/TestData/Manual/PackageA/PackageA.wixproj index c9c81c3a..61dc27ab 100644 --- a/src/test/burn/TestData/Manual/PackageA/PackageA.wixproj +++ b/src/test/burn/TestData/Manual/PackageA/PackageA.wixproj @@ -2,8 +2,12 @@ {0D803A6E-8090-4174-8DAC-810ECC2B1BBF} + true + + + \ No newline at end of file diff --git a/src/test/burn/TestData/Manual/PackageA/ProductA.wxs b/src/test/burn/TestData/Manual/PackageA/ProductA.wxs new file mode 100644 index 00000000..bf1ef152 --- /dev/null +++ b/src/test/burn/TestData/Manual/PackageA/ProductA.wxs @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + -- cgit v1.2.3-55-g6feb