215 lines
7.7 KiB
Diff
215 lines
7.7 KiB
Diff
CPP/7zip/Bundles/SFXSetup/Compat.xml | 12 +++++++
|
|
CPP/7zip/Bundles/SFXSetup/SfxSetup.cpp | 52 ++++++++++++++++++++++++------
|
|
CPP/7zip/Bundles/SFXSetup/resource.rc | 4 +--
|
|
CPP/7zip/UI/Explorer/MyMessages.cpp | 4 +--
|
|
CPP/7zip/UI/Explorer/MyMessages.h | 2 +-
|
|
CPP/7zip/UI/FileManager/FormatUtils.cpp | 2 +-
|
|
CPP/7zip/UI/FileManager/ProgressDialog.cpp | 4 +--
|
|
7 files changed, 63 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/CPP/7zip/Bundles/SFXSetup/Compat.xml b/CPP/7zip/Bundles/SFXSetup/Compat.xml
|
|
new file mode 100644
|
|
index 0000000..632a8fa
|
|
--- /dev/null
|
|
+++ b/CPP/7zip/Bundles/SFXSetup/Compat.xml
|
|
@@ -0,0 +1,12 @@
|
|
+<?xml version="1.0" encoding="utf-8"?>
|
|
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
|
+ <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
|
+ <application>
|
|
+ <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
|
+ <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
|
+ <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
|
+ <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
|
+ <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
|
+ </application>
|
|
+ </compatibility>
|
|
+</assembly>
|
|
diff --git a/CPP/7zip/Bundles/SFXSetup/SfxSetup.cpp b/CPP/7zip/Bundles/SFXSetup/SfxSetup.cpp
|
|
index aef2e19..7f856f1 100644
|
|
--- a/CPP/7zip/Bundles/SFXSetup/SfxSetup.cpp
|
|
+++ b/CPP/7zip/Bundles/SFXSetup/SfxSetup.cpp
|
|
@@ -37,6 +37,27 @@ static CFSTR kTempDirPrefix = FTEXT("7zS");
|
|
|
|
#define _SHELL_EXECUTE
|
|
|
|
+static HWND GetCurrentHwnd(void)
|
|
+{
|
|
+ HWND result = ::GetActiveWindow();
|
|
+ if(!result)
|
|
+ {
|
|
+ for (int i = 0; i < 256; ++i)
|
|
+ {
|
|
+ if(i > 0)
|
|
+ {
|
|
+ ::Sleep(1); /*some delay*/
|
|
+ }
|
|
+ result = ::GetForegroundWindow();
|
|
+ if(result)
|
|
+ {
|
|
+ break; /*done*/
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ return result;
|
|
+}
|
|
+
|
|
static bool ReadDataString(CFSTR fileName, LPCSTR startID,
|
|
LPCSTR endID, AString &stringResult)
|
|
{
|
|
@@ -145,7 +166,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
|
|
|
|
UString archiveName, switches;
|
|
#ifdef _SHELL_EXECUTE
|
|
- UString executeFile, executeParameters;
|
|
+ UString executeFile, executeParameters, executeErrorMsg;
|
|
#endif
|
|
NCommandLineParser::SplitCommandLine(GetCommandLineW(), archiveName, switches);
|
|
|
|
@@ -191,7 +212,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
|
|
dirPrefix = pairs[index].String;
|
|
if (!installPrompt.IsEmpty() && !assumeYes)
|
|
{
|
|
- if (MessageBoxW(0, installPrompt, friendlyName, MB_YESNO |
|
|
+ if (MessageBoxW(NULL, installPrompt, friendlyName, MB_YESNO | MB_SYSTEMMODAL |
|
|
MB_ICONQUESTION) != IDYES)
|
|
return 0;
|
|
}
|
|
@@ -200,6 +221,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
|
|
#ifdef _SHELL_EXECUTE
|
|
executeFile = GetTextConfigValue(pairs, L"ExecuteFile");
|
|
executeParameters = GetTextConfigValue(pairs, L"ExecuteParameters");
|
|
+ executeErrorMsg = GetTextConfigValue(pairs, L"ExecuteErrorMsg");
|
|
#endif
|
|
}
|
|
|
|
@@ -243,7 +265,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
|
|
{
|
|
if (errorMessage.IsEmpty())
|
|
errorMessage = NError::MyFormatMessage(result);
|
|
- ::MessageBoxW(0, errorMessage, NWindows::MyLoadString(IDS_EXTRACTION_ERROR_TITLE), MB_ICONERROR);
|
|
+ ::MessageBoxW(NULL, errorMessage, NWindows::MyLoadString(IDS_EXTRACTION_ERROR_TITLE), MB_ICONERROR | MB_SYSTEMMODAL);
|
|
}
|
|
}
|
|
return 1;
|
|
@@ -287,13 +309,25 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
|
|
execInfo.lpDirectory = NULL;
|
|
execInfo.nShow = SW_SHOWNORMAL;
|
|
execInfo.hProcess = 0;
|
|
- /* BOOL success = */ ::ShellExecuteEx(&execInfo);
|
|
- UINT32 result = (UINT32)(UINT_PTR)execInfo.hInstApp;
|
|
- if (result <= 32)
|
|
+
|
|
+ for (;;)
|
|
{
|
|
- if (!assumeYes)
|
|
- ShowErrorMessage(L"Can not open file");
|
|
- return 1;
|
|
+ execInfo.hwnd = GetCurrentHwnd(); /*prevent UAC dialog from appearing in the background!*/
|
|
+ /* BOOL success = */ ::ShellExecuteEx(&execInfo);
|
|
+ UINT32 result = (UINT32)(UINT_PTR)execInfo.hInstApp;
|
|
+ if (result <= 32)
|
|
+ {
|
|
+ if (!assumeYes)
|
|
+ {
|
|
+ const wchar_t *const lpErrorMessage = executeErrorMsg.IsEmpty() ? L"Failed to launch installer. Please try again!" : executeErrorMsg;
|
|
+ if (MessageBoxW(NULL, lpErrorMessage, L"Setup", MB_SYSTEMMODAL | MB_ICONEXCLAMATION | MB_RETRYCANCEL) == IDRETRY)
|
|
+ {
|
|
+ continue; /*retry*/
|
|
+ }
|
|
+ }
|
|
+ return 1;
|
|
+ }
|
|
+ break; /*success*/
|
|
}
|
|
hProcess = execInfo.hProcess;
|
|
}
|
|
diff --git a/CPP/7zip/Bundles/SFXSetup/resource.rc b/CPP/7zip/Bundles/SFXSetup/resource.rc
|
|
index 47e1b76..c796e65 100644
|
|
--- a/CPP/7zip/Bundles/SFXSetup/resource.rc
|
|
+++ b/CPP/7zip/Bundles/SFXSetup/resource.rc
|
|
@@ -1,14 +1,14 @@
|
|
#include "../../MyVersionInfo.rc"
|
|
#include "resource.h"
|
|
|
|
-MY_VERSION_INFO_APP("7z Setup SFX", "7zS.sfx")
|
|
+MY_VERSION_INFO_APP("Setup SFX", "7zS.sfx")
|
|
|
|
IDI_ICON ICON "setup.ico"
|
|
|
|
STRINGTABLE
|
|
BEGIN
|
|
IDS_EXTRACTION_ERROR_TITLE "Extraction Failed"
|
|
- IDS_EXTRACTION_ERROR_MESSAGE "File is corrupt"
|
|
+ IDS_EXTRACTION_ERROR_MESSAGE "File is corrupt. Please download again!"
|
|
IDS_CANNOT_CREATE_FOLDER "Cannot create folder '{0}'"
|
|
IDS_PROGRESS_EXTRACTING "Extracting"
|
|
END
|
|
diff --git a/CPP/7zip/UI/Explorer/MyMessages.cpp b/CPP/7zip/UI/Explorer/MyMessages.cpp
|
|
index 70c2a46..84ac8f4 100644
|
|
--- a/CPP/7zip/UI/Explorer/MyMessages.cpp
|
|
+++ b/CPP/7zip/UI/Explorer/MyMessages.cpp
|
|
@@ -1,6 +1,6 @@
|
|
// MyMessages.cpp
|
|
|
|
-#include "StdAfx.h"
|
|
+//#include "StdAfx.h"
|
|
|
|
#include "MyMessages.h"
|
|
|
|
@@ -13,7 +13,7 @@ using namespace NWindows;
|
|
|
|
void ShowErrorMessage(HWND window, LPCWSTR message)
|
|
{
|
|
- ::MessageBoxW(window, message, L"7-Zip", MB_OK | MB_ICONSTOP);
|
|
+ ::MessageBoxW(window, message, L"Setup", MB_OK | MB_SYSTEMMODAL | MB_ICONSTOP);
|
|
}
|
|
|
|
void ShowErrorMessageHwndRes(HWND window, UINT resID)
|
|
diff --git a/CPP/7zip/UI/Explorer/MyMessages.h b/CPP/7zip/UI/Explorer/MyMessages.h
|
|
index d5822f4..3bd6e2e 100644
|
|
--- a/CPP/7zip/UI/Explorer/MyMessages.h
|
|
+++ b/CPP/7zip/UI/Explorer/MyMessages.h
|
|
@@ -6,7 +6,7 @@
|
|
#include "../../../Common/MyString.h"
|
|
|
|
void ShowErrorMessage(HWND window, LPCWSTR message);
|
|
-inline void ShowErrorMessage(LPCWSTR message) { ShowErrorMessage(0, message); }
|
|
+inline void ShowErrorMessage(LPCWSTR message) { ShowErrorMessage(NULL, message); }
|
|
|
|
void ShowErrorMessageHwndRes(HWND window, UInt32 langID);
|
|
void ShowErrorMessageRes(UInt32 langID);
|
|
diff --git a/CPP/7zip/UI/FileManager/FormatUtils.cpp b/CPP/7zip/UI/FileManager/FormatUtils.cpp
|
|
index 2143c3f..3a18712 100644
|
|
--- a/CPP/7zip/UI/FileManager/FormatUtils.cpp
|
|
+++ b/CPP/7zip/UI/FileManager/FormatUtils.cpp
|
|
@@ -1,6 +1,6 @@
|
|
// FormatUtils.cpp
|
|
|
|
-#include "StdAfx.h"
|
|
+//#include "StdAfx.h"
|
|
|
|
#include "../../../Common/IntToString.h"
|
|
|
|
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.cpp b/CPP/7zip/UI/FileManager/ProgressDialog.cpp
|
|
index 65201a9..4d23499 100644
|
|
--- a/CPP/7zip/UI/FileManager/ProgressDialog.cpp
|
|
+++ b/CPP/7zip/UI/FileManager/ProgressDialog.cpp
|
|
@@ -1,6 +1,6 @@
|
|
// ProgressDialog.cpp
|
|
|
|
-#include "StdAfx.h"
|
|
+//#include "StdAfx.h"
|
|
|
|
#include "../../../Common/IntToString.h"
|
|
|
|
@@ -165,7 +165,7 @@ bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
|
|
bool paused = Sync.GetPaused();
|
|
Sync.SetPaused(true);
|
|
_inCancelMessageBox = true;
|
|
- int res = ::MessageBoxW(*this, L"Are you sure you want to cancel?", _title, MB_YESNOCANCEL);
|
|
+ int res = ::MessageBoxW(*this, L"Are you sure you want to cancel?", _title, MB_YESNOCANCEL | MB_SYSTEMMODAL);
|
|
_inCancelMessageBox = false;
|
|
Sync.SetPaused(paused);
|
|
if (res == IDCANCEL || res == IDNO)
|