Don't show FilesInUse dialogs if loc strings are missing.
This allows all flavors of wixstdba to conditionally support them.
Sean Hall committed
Jul 24, 2022 at 14:10 UTC
8797650acd990ef71f143150b873b5b7a09db86d
4 files changed
+140
-75
src/ext/Bal/wixstdba/Resources/dncpreq.wxl
+8
@@ -30,4 +30,12 @@
30
<String Id="FailureCloseButton">&Close</String>
31
<String Id="SCDRUNTIMEFAILUREErrorMessage">[WixBundleName] cannot run on this machine. Install the latest updates and/or the latest OS to run in a supported environment.</String>
32
<String Id="PREREQBAINFINITELOOPErrorMessage">[WixBundleName] failed to load the .NET Core runtime even though all of the prerequisites are installed.</String>
33
+ <String Id="FilesInUseTitle">Files In Use</String>
34
+ <String Id="FilesInUseLabel">The following applications are using files that need to be updated:</String>
35
+ <String Id="FilesInUseNetfxCloseRadioButton">Close the &applications.</String>
36
+ <String Id="FilesInUseCloseRadioButton">Close the &applications and attempt to restart them.</String>
37
+ <String Id="FilesInUseDontCloseRadioButton">&Do not close applications. A reboot will be required.</String>
38
+ <String Id="FilesInUseRetryButton">&Retry</String>
39
+ <String Id="FilesInUseIgnoreButton">&Ignore</String>
40
+ <String Id="FilesInUseExitButton">E&xit</String>
41
</WixLocalization>
src/ext/Bal/wixstdba/Resources/iuipreq.wxl
+8
-1
@@ -30,5 +30,12 @@
30
<String Id="FailureRestartText">You must restart your computer to complete the rollback of the software.</String>
31
<String Id="FailureRestartButton">&Restart</String>
32
<String Id="FailureCloseButton">&Close</String>
33
- <String Id="ErrorFailNoActionReboot">No action was taken as a system reboot is required.</String>
33
+ <String Id="FilesInUseTitle">Files In Use</String>
34
+ <String Id="FilesInUseLabel">The following applications are using files that need to be updated:</String>
35
+ <String Id="FilesInUseNetfxCloseRadioButton">Close the &applications.</String>
36
+ <String Id="FilesInUseCloseRadioButton">Close the &applications and attempt to restart them.</String>
37
+ <String Id="FilesInUseDontCloseRadioButton">&Do not close applications. A reboot will be required.</String>
38
+ <String Id="FilesInUseRetryButton">&Retry</String>
39
+ <String Id="FilesInUseIgnoreButton">&Ignore</String>
40
+ <String Id="FilesInUseExitButton">E&xit</String>
41
</WixLocalization>
src/ext/Bal/wixstdba/Resources/mbapreq.wxl
+8
@@ -30,4 +30,12 @@
30
<String Id="FailureCloseButton">&Close</String>
31
<String Id="NET452WIN7RTMErrorMessage">[WixBundleName] cannot run on Windows 7 RTM with .NET 4.5.2 installed. Install Windows 7 SP1 to run in a supported environment.</String>
32
<String Id="PREREQBAINFINITELOOPErrorMessage">[WixBundleName] failed to load the .NET Framework runtime even though all of the prerequisites are installed.</String>
33
+ <String Id="FilesInUseTitle">Files In Use</String>
34
+ <String Id="FilesInUseLabel">The following applications are using files that need to be updated:</String>
35
+ <String Id="FilesInUseNetfxCloseRadioButton">Close the &applications.</String>
36
+ <String Id="FilesInUseCloseRadioButton">Close the &applications and attempt to restart them.</String>
37
+ <String Id="FilesInUseDontCloseRadioButton">&Do not close applications. A reboot will be required.</String>
38
+ <String Id="FilesInUseRetryButton">&Retry</String>
39
+ <String Id="FilesInUseIgnoreButton">&Ignore</String>
40
+ <String Id="FilesInUseExitButton">E&xit</String>
41
</WixLocalization>
src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
+116
-74
@@ -1049,17 +1049,30 @@ public: // IBootstrapperApplication
1049
)
1050
{
1051
1052
- if (!m_fShowingInternalUiThisPackage && !m_fPrereq && wzPackageId && *wzPackageId)
1052
+ if (!m_fShowingInternalUiThisPackage && wzPackageId && *wzPackageId)
1053
{
1054
BalLog(BOOTSTRAPPER_LOG_LEVEL_VERBOSE, "Package %ls has %d applications holding files in use.", wzPackageId, cFiles);
1055
1056
switch (source)
1057
{
1058
case BOOTSTRAPPER_FILES_IN_USE_TYPE_MSI:
1059
+ if (m_fShowStandardFilesInUse)
1060
+ {
1061
+ return ShowMsiFilesInUse(cFiles, rgwzFiles, source, pResult);
1062
+ }
1063
+ break;
1064
case BOOTSTRAPPER_FILES_IN_USE_TYPE_MSI_RM:
1060
- return ShowMsiFilesInUse(cFiles, rgwzFiles, source, pResult);
1065
+ if (m_fShowRMFilesInUse)
1066
+ {
1067
+ return ShowMsiFilesInUse(cFiles, rgwzFiles, source, pResult);
1068
+ }
1069
+ break;
1070
case BOOTSTRAPPER_FILES_IN_USE_TYPE_NETFX:
1062
- return ShowNetfxFilesInUse(cFiles, rgwzFiles, pResult);
1071
+ if (m_fShowNetfxFilesInUse)
1072
+ {
1073
+ return ShowNetfxFilesInUse(cFiles, rgwzFiles, pResult);
1074
+ }
1075
+ break;
1076
}
1077
}
1078
@@ -2289,34 +2302,20 @@ private: // privates
2302
LPWSTR sczLabel = NULL;
2303
LPWSTR sczCloseRadioButton = NULL;
2304
LPWSTR sczDontCloseRadioButton = NULL;
2292
- LOC_STRING* pLocString = NULL;
2305
int nButton = 0;
2306
int nRadioButton = 0;
2307
2296
- // Get the loc strings for the files-in-use task dialog text.
2297
- hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseTitle)", &pLocString);
2298
- BalExitOnFailure(hr, "Failed to get FilesInUseTitle loc string.");
2299
-
2300
- hr = StrAllocString(&sczTitle, pLocString->wzText, 0);
2301
- BalExitOnFailure(hr, "Failed to copy FilesInUseTitle loc string.");
2308
+ hr = BalFormatString(m_pFilesInUseTitleLoc->wzText, &sczTitle);
2309
+ BalExitOnFailure(hr, "Failed to format FilesInUseTitle loc string.");
2310
2303
- hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseLabel)", &pLocString);
2304
- BalExitOnFailure(hr, "Failed to get FilesInUseLabel loc string.");
2311
+ hr = BalFormatString(m_pFilesInUseLabelLoc->wzText, &sczLabel);
2312
+ BalExitOnFailure(hr, "Failed to format FilesInUseLabel loc string.");
2313
2306
- hr = StrAllocString(&sczLabel, pLocString->wzText, 0);
2307
- BalExitOnFailure(hr, "Failed to copy FilesInUseLabel loc string.");
2314
+ hr = BalFormatString(m_pFilesInUseCloseRadioButtonLoc->wzText, &sczCloseRadioButton);
2315
+ BalExitOnFailure(hr, "Failed to format FilesInUseCloseRadioButton loc string.");
2316
2309
- hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseCloseRadioButton)", &pLocString);
2310
- BalExitOnFailure(hr, "Failed to get FilesInUseCloseRadioButton loc string.");
2311
-
2312
- hr = StrAllocString(&sczCloseRadioButton, pLocString->wzText, 0);
2313
- BalExitOnFailure(hr, "Failed to copy FilesInUseCloseRadioButton loc string.");
2314
-
2315
- hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseDontCloseRadioButton)", &pLocString);
2316
- BalExitOnFailure(hr, "Failed to get FilesInUseDontCloseRadioButton loc string.");
2317
-
2318
- hr = StrAllocString(&sczDontCloseRadioButton, pLocString->wzText, 0);
2319
- BalExitOnFailure(hr, "Failed to copy FilesInUseDontCloseRadioButton loc string.");
2317
+ hr = BalFormatString(m_pFilesInUseDontCloseRadioButtonLoc->wzText, &sczDontCloseRadioButton);
2318
+ BalExitOnFailure(hr, "Failed to format FilesInUseDontCloseRadioButton loc string.");
2319
2320
const TASKDIALOG_BUTTON rgRadioButtons[] = {
2321
{ IDOK, sczCloseRadioButton },
@@ -2346,6 +2345,11 @@ private: // privates
2345
#endif
2346
2347
LExit:
2348
+ ReleaseStr(sczTitle);
2349
+ ReleaseStr(sczLabel);
2350
+ ReleaseStr(sczCloseRadioButton);
2351
+ ReleaseStr(sczDontCloseRadioButton);
2352
+
2353
return hr;
2354
}
2355
@@ -2362,38 +2366,21 @@ private: // privates
2366
LPWSTR sczRetryButton = NULL;
2367
LPWSTR sczIgnoreButton = NULL;
2368
LPWSTR sczExitButton = NULL;
2365
- LOC_STRING* pLocString = NULL;
2366
-
2367
- // Get the loc strings for the files-in-use task dialog text.
2368
- hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseTitle)", &pLocString);
2369
- BalExitOnFailure(hr, "Failed to get FilesInUseTitle loc string.");
2369
2371
- hr = StrAllocString(&sczTitle, pLocString->wzText, 0);
2372
- BalExitOnFailure(hr, "Failed to copy FilesInUseTitle loc string.");
2370
+ hr = BalFormatString(m_pFilesInUseTitleLoc->wzText, &sczTitle);
2371
+ BalExitOnFailure(hr, "Failed to format FilesInUseTitle loc string.");
2372
2374
- hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseLabel)", &pLocString);
2375
- BalExitOnFailure(hr, "Failed to get FilesInUseLabel loc string.");
2373
+ hr = BalFormatString(m_pFilesInUseLabelLoc->wzText, &sczLabel);
2374
+ BalExitOnFailure(hr, "Failed to format FilesInUseLabel loc string.");
2375
2377
- hr = StrAllocString(&sczLabel, pLocString->wzText, 0);
2378
- BalExitOnFailure(hr, "Failed to copy FilesInUseLabel loc string.");
2376
+ hr = BalFormatString(m_pFilesInUseRetryButtonLoc->wzText, &sczRetryButton);
2377
+ BalExitOnFailure(hr, "Failed to format FilesInUseRetryButton loc string.");
2378
2380
- hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseRetryButton)", &pLocString);
2381
- BalExitOnFailure(hr, "Failed to get FilesInUseRetryButton loc string.");
2379
+ hr = BalFormatString(m_pFilesInUseIgnoreButtonLoc->wzText, &sczIgnoreButton);
2380
+ BalExitOnFailure(hr, "Failed to format FilesInUseIgnoreButton loc string.");
2381
2383
- hr = StrAllocString(&sczRetryButton, pLocString->wzText, 0);
2384
- BalExitOnFailure(hr, "Failed to copy FilesInUseRetryButton loc string.");
2385
-
2386
- hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseIgnoreButton)", &pLocString);
2387
- BalExitOnFailure(hr, "Failed to get FilesInUseIgnoreButton loc string.");
2388
-
2389
- hr = StrAllocString(&sczIgnoreButton, pLocString->wzText, 0);
2390
- BalExitOnFailure(hr, "Failed to copy FilesInUseIgnoreButton loc string.");
2391
-
2392
- hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseExitButton)", &pLocString);
2393
- BalExitOnFailure(hr, "Failed to get FilesInUseExitButton loc string.");
2394
-
2395
- hr = StrAllocString(&sczExitButton, pLocString->wzText, 0);
2396
- BalExitOnFailure(hr, "Failed to copy FilesInUseExitButton loc string.");
2382
+ hr = BalFormatString(m_pFilesInUseExitButtonLoc->wzText, &sczExitButton);
2383
+ BalExitOnFailure(hr, "Failed to format FilesInUseExitButton loc string.");
2384
2385
const TASKDIALOG_BUTTON rgButtons[] = {
2386
{ IDRETRY, sczRetryButton },
@@ -2419,6 +2406,12 @@ private: // privates
2406
#endif
2407
2408
LExit:
2409
+ ReleaseStr(sczTitle);
2410
+ ReleaseStr(sczLabel);
2411
+ ReleaseStr(sczRetryButton);
2412
+ ReleaseStr(sczIgnoreButton);
2413
+ ReleaseStr(sczExitButton);
2414
+
2415
return hr;
2416
}
2417
@@ -2485,34 +2478,20 @@ private: // privates
2478
LPWSTR sczLabel = NULL;
2479
LPWSTR sczNetfxCloseRadioButton = NULL;
2480
LPWSTR sczDontCloseRadioButton = NULL;
2488
- LOC_STRING* pLocString = NULL;
2481
int nButton = 0;
2482
int nRadioButton = 0;
2483
2492
- // Get the loc strings for the files-in-use task dialog text.
2493
- hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseTitle)", &pLocString);
2494
- BalExitOnFailure(hr, "Failed to get FilesInUseTitle loc string.");
2495
-
2496
- hr = StrAllocString(&sczTitle, pLocString->wzText, 0);
2497
- BalExitOnFailure(hr, "Failed to copy FilesInUseTitle loc string.");
2498
-
2499
- hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseLabel)", &pLocString);
2500
- BalExitOnFailure(hr, "Failed to get FilesInUseLabel loc string.");
2484
+ hr = BalFormatString(m_pFilesInUseTitleLoc->wzText, &sczTitle);
2485
+ BalExitOnFailure(hr, "Failed to format FilesInUseTitle loc string.");
2486
2502
- hr = StrAllocString(&sczLabel, pLocString->wzText, 0);
2503
- BalExitOnFailure(hr, "Failed to copy FilesInUseLabel loc string.");
2487
+ hr = BalFormatString(m_pFilesInUseLabelLoc->wzText, &sczLabel);
2488
+ BalExitOnFailure(hr, "Failed to format FilesInUseLabel loc string.");
2489
2505
- hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseNetfxCloseRadioButton)", &pLocString);
2506
- BalExitOnFailure(hr, "Failed to get FilesInUseNetfxCloseRadioButton loc string.");
2490
+ hr = BalFormatString(m_pFilesInUseNetfxCloseRadioButtonLoc->wzText, &sczNetfxCloseRadioButton);
2491
+ BalExitOnFailure(hr, "Failed to format FilesInUseNetfxCloseRadioButton loc string.");
2492
2508
- hr = StrAllocString(&sczNetfxCloseRadioButton, pLocString->wzText, 0);
2509
- BalExitOnFailure(hr, "Failed to copy FilesInUseNetfxCloseRadioButton loc string.");
2510
-
2511
- hr = LocGetString(m_pWixLoc, L"#(loc.FilesInUseDontCloseRadioButton)", &pLocString);
2512
- BalExitOnFailure(hr, "Failed to get FilesInUseDontCloseRadioButton loc string.");
2513
-
2514
- hr = StrAllocString(&sczDontCloseRadioButton, pLocString->wzText, 0);
2515
- BalExitOnFailure(hr, "Failed to copy FilesInUseDontCloseRadioButton loc string.");
2493
+ hr = BalFormatString(m_pFilesInUseDontCloseRadioButtonLoc->wzText, &sczDontCloseRadioButton);
2494
+ BalExitOnFailure(hr, "Failed to format FilesInUseDontCloseRadioButton loc string.");
2495
2496
const TASKDIALOG_BUTTON rgRadioButtons[] = {
2497
{ IDYES, sczNetfxCloseRadioButton },
@@ -2542,6 +2521,11 @@ private: // privates
2521
#endif
2522
2523
LExit:
2524
+ ReleaseStr(sczTitle);
2525
+ ReleaseStr(sczLabel);
2526
+ ReleaseStr(sczNetfxCloseRadioButton);
2527
+ ReleaseStr(sczDontCloseRadioButton);
2528
+
2529
return hr;
2530
}
2531
@@ -2736,6 +2720,8 @@ private:
2720
hr = LoadLocalization(sczModulePath, m_sczLanguage);
2721
ExitOnFailure(hr, "Failed to load localization.");
2722
2723
+ LoadFilesInUse();
2724
+
2725
hr = LoadTheme(sczModulePath, m_sczLanguage);
2726
ExitOnFailure(hr, "Failed to load theme.");
2727
@@ -2898,6 +2884,40 @@ private:
2884
}
2885
2886
2887
+ HRESULT LoadIndividualLocString(
2888
+ __in_z LPCWSTR wzId,
2889
+ __out LOC_STRING** ppLocString
2890
+ )
2891
+ {
2892
+ HRESULT hr = LocGetString(m_pWixLoc, wzId, ppLocString);
2893
+
2894
+ if (E_NOTFOUND == hr)
2895
+ {
2896
+ BalLog(BOOTSTRAPPER_LOG_LEVEL_DEBUG, "WIXSTDBA: Missing loc string '%ls'.", wzId);
2897
+ }
2898
+
2899
+ return hr;
2900
+ }
2901
+
2902
+
2903
+ void LoadFilesInUse()
2904
+ {
2905
+ // Get the loc strings for the files-in-use dialogs.
2906
+ LoadIndividualLocString(L"#(loc.FilesInUseTitle)", &m_pFilesInUseTitleLoc);
2907
+ LoadIndividualLocString(L"#(loc.FilesInUseLabel)", &m_pFilesInUseLabelLoc);
2908
+ LoadIndividualLocString(L"#(loc.FilesInUseCloseRadioButton)", &m_pFilesInUseCloseRadioButtonLoc);
2909
+ LoadIndividualLocString(L"#(loc.FilesInUseDontCloseRadioButton)", &m_pFilesInUseDontCloseRadioButtonLoc);
2910
+ LoadIndividualLocString(L"#(loc.FilesInUseRetryButton)", &m_pFilesInUseRetryButtonLoc);
2911
+ LoadIndividualLocString(L"#(loc.FilesInUseIgnoreButton)", &m_pFilesInUseIgnoreButtonLoc);
2912
+ LoadIndividualLocString(L"#(loc.FilesInUseExitButton)", &m_pFilesInUseExitButtonLoc);
2913
+ LoadIndividualLocString(L"#(loc.FilesInUseNetfxCloseRadioButton)", &m_pFilesInUseNetfxCloseRadioButtonLoc);
2914
+
2915
+ m_fShowRMFilesInUse = m_pFilesInUseTitleLoc && m_pFilesInUseLabelLoc && m_pFilesInUseCloseRadioButtonLoc && m_pFilesInUseDontCloseRadioButtonLoc;
2916
+ m_fShowStandardFilesInUse = m_pFilesInUseTitleLoc && m_pFilesInUseLabelLoc && m_pFilesInUseRetryButtonLoc && m_pFilesInUseIgnoreButtonLoc && m_pFilesInUseExitButtonLoc;
2917
+ m_fShowNetfxFilesInUse = m_pFilesInUseTitleLoc && m_pFilesInUseLabelLoc && m_pFilesInUseNetfxCloseRadioButtonLoc && m_pFilesInUseDontCloseRadioButtonLoc;
2918
+ }
2919
+
2920
+
2921
HRESULT LoadTheme(
2922
__in_z LPCWSTR wzModulePath,
2923
__in_z_opt LPCWSTR wzLanguage
@@ -4631,8 +4651,19 @@ public:
4651
m_fPrereqInstalled = FALSE;
4652
m_fPrereqSkipped = FALSE;
4653
4654
+ m_fShowStandardFilesInUse = FALSE;
4655
+ m_fShowRMFilesInUse = FALSE;
4656
+ m_fShowNetfxFilesInUse = FALSE;
4657
m_nLastMsiFilesInUseResult = IDNOACTION;
4658
m_nLastNetfxFilesInUseResult = IDNOACTION;
4659
+ m_pFilesInUseTitleLoc = NULL;
4660
+ m_pFilesInUseLabelLoc = NULL;
4661
+ m_pFilesInUseCloseRadioButtonLoc = NULL;
4662
+ m_pFilesInUseNetfxCloseRadioButtonLoc = NULL;
4663
+ m_pFilesInUseDontCloseRadioButtonLoc = NULL;
4664
+ m_pFilesInUseRetryButtonLoc = NULL;
4665
+ m_pFilesInUseIgnoreButtonLoc = NULL;
4666
+ m_pFilesInUseExitButtonLoc = NULL;
4667
4668
pEngine->AddRef();
4669
m_pEngine = pEngine;
@@ -4926,8 +4957,19 @@ private:
4957
BOOL m_fShowingInternalUiThisPackage;
4958
BOOL m_fTriedToLaunchElevated;
4959
4960
+ BOOL m_fShowStandardFilesInUse;
4961
+ BOOL m_fShowRMFilesInUse;
4962
+ BOOL m_fShowNetfxFilesInUse;
4963
int m_nLastMsiFilesInUseResult;
4964
int m_nLastNetfxFilesInUseResult;
4965
+ LOC_STRING* m_pFilesInUseTitleLoc;
4966
+ LOC_STRING* m_pFilesInUseLabelLoc;
4967
+ LOC_STRING* m_pFilesInUseCloseRadioButtonLoc;
4968
+ LOC_STRING* m_pFilesInUseNetfxCloseRadioButtonLoc;
4969
+ LOC_STRING* m_pFilesInUseDontCloseRadioButtonLoc;
4970
+ LOC_STRING* m_pFilesInUseRetryButtonLoc;
4971
+ LOC_STRING* m_pFilesInUseIgnoreButtonLoc;
4972
+ LOC_STRING* m_pFilesInUseExitButtonLoc;
4973
4974
HMODULE m_hBAFModule;
4975
PFN_BA_FUNCTIONS_PROC m_pfnBAFunctionsProc;