This commit is contained in:
Igor Pavlov
2023-12-22 17:17:05 +00:00
committed by Kornel
parent ec44a8a070
commit a36c48cece
954 changed files with 42199 additions and 25482 deletions

View File

@@ -7,8 +7,11 @@
#endif
#include "../../../Common/MyWindows.h"
#if defined(__MINGW32__) || defined(__MINGW64__)
#include <shlwapi.h>
#else
#include <Shlwapi.h>
#endif
#include "../../../Common/MyInitGuid.h"
@@ -23,7 +26,7 @@
#include "../Common/ExitCode.h"
#include "../FileManager/StringUtils.h"
#include "../FileManager/MyWindowsNew.h"
#include "../FileManager/LangUtils.h"
#include "BenchmarkDialog.h"
#include "ExtractGUI.h"
@@ -34,7 +37,9 @@
using namespace NWindows;
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
extern
const CExternalCodecs *g_ExternalCodecs_Ptr;
const CExternalCodecs *g_ExternalCodecs_Ptr;
#endif
@@ -51,20 +56,23 @@ DWORD g_ComCtl32Version;
static DWORD GetDllVersion(LPCTSTR dllName)
{
DWORD dwVersion = 0;
HINSTANCE hinstDll = LoadLibrary(dllName);
if (hinstDll)
const HMODULE hmodule = LoadLibrary(dllName);
if (hmodule)
{
DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)(void *)GetProcAddress(hinstDll, "DllGetVersion");
if (pDllGetVersion)
const
DLLGETVERSIONPROC f_DllGetVersion = Z7_GET_PROC_ADDRESS(
DLLGETVERSIONPROC, hmodule,
"DllGetVersion");
if (f_DllGetVersion)
{
DLLVERSIONINFO dvi;
ZeroMemory(&dvi, sizeof(dvi));
dvi.cbSize = sizeof(dvi);
HRESULT hr = (*pDllGetVersion)(&dvi);
const HRESULT hr = (*f_DllGetVersion)(&dvi);
if (SUCCEEDED(hr))
dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
dwVersion = (DWORD)MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
}
FreeLibrary(hinstDll);
FreeLibrary(hmodule);
}
return dwVersion;
}
@@ -100,9 +108,9 @@ static int ShowMemErrorMessage()
return NExitCode::kMemoryError;
}
static int ShowSysErrorMessage(DWORD errorCode)
static int ShowSysErrorMessage(HRESULT errorCode)
{
if ((HRESULT)errorCode == E_OUTOFMEMORY)
if (errorCode == E_OUTOFMEMORY)
return ShowMemErrorMessage();
ErrorMessage(HResultToMessage(errorCode));
return NExitCode::kFatalError;
@@ -125,7 +133,7 @@ static int Main2()
#endif
if (commandStrings.Size() == 0)
{
MessageBoxW(0, L"Specify command", L"7-Zip", 0);
MessageBoxW(NULL, L"Specify command", L"7-Zip", 0);
return 0;
}
@@ -142,14 +150,14 @@ static int Main2()
ThrowException_if_Error(codecs->Load());
Codecs_AddHashArcHandler(codecs);
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
{
g_ExternalCodecs_Ptr = &__externalCodecs;
g_ExternalCodecs_Ptr = &_externalCodecs;
UString s;
codecs->GetCodecsErrorMessage(s);
if (!s.IsEmpty())
{
MessageBoxW(0, s, L"7-Zip", MB_ICONERROR);
MessageBoxW(NULL, s, L"7-Zip", MB_ICONERROR);
}
}
@@ -162,7 +170,7 @@ static int Main2()
|| options.Command.IsFromUpdateGroup()))
{
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
if (!codecs->MainDll_ErrorPath.IsEmpty())
{
UString s ("7-Zip cannot load module: ");
@@ -194,12 +202,12 @@ static int Main2()
// excludedFormats.Sort();
}
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
if (isExtractGroupCommand
|| options.Command.IsFromUpdateGroup()
|| options.Command.CommandType == NCommandType::kHash
|| options.Command.CommandType == NCommandType::kBenchmark)
ThrowException_if_Error(__externalCodecs.Load());
ThrowException_if_Error(_externalCodecs.Load());
#endif
if (options.Command.CommandType == NCommandType::kBenchmark)
@@ -227,7 +235,7 @@ static int Main2()
CExtractCallbackImp *ecs = new CExtractCallbackImp;
CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
ecs->PasswordIsDefined = options.PasswordEnabled;
ecs->Password = options.Password;
#endif
@@ -241,13 +249,13 @@ static int Main2()
eo.YesToAll = options.YesToAll;
eo.TestMode = options.Command.IsTestCommand();
#ifndef _SFX
#ifndef Z7_SFX
eo.Properties = options.Properties;
#endif
bool messageWasDisplayed = false;
#ifndef _SFX
#ifndef Z7_SFX
CHashBundle hb;
CHashBundle *hb_ptr = NULL;
@@ -289,7 +297,7 @@ static int Main2()
ArchivePathsFullSorted,
options.Censor.Pairs.Front().Head,
eo,
#ifndef _SFX
#ifndef Z7_SFX
hb_ptr,
#endif
options.ShowDialog, messageWasDisplayed, ecs);
@@ -304,14 +312,14 @@ static int Main2()
}
else if (options.Command.IsFromUpdateGroup())
{
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
bool passwordIsDefined = options.PasswordEnabled && !options.Password.IsEmpty();
#endif
CUpdateCallbackGUI callback;
// callback.EnablePercents = options.EnablePercents;
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
callback.PasswordIsDefined = passwordIsDefined;
callback.AskPassword = options.PasswordEnabled && options.Password.IsEmpty();
callback.Password = options.Password;
@@ -407,7 +415,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
OleInitialize(NULL);
#endif
#ifdef Z7_LANG
LoadLangOneTime();
#endif
// setlocale(LC_COLLATE, ".ACP");
try
@@ -456,7 +466,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
catch(int v)
{
AString e ("Error: ");
e.Add_UInt32(v);
e.Add_UInt32((unsigned)v);
ErrorMessage(e);
return NExitCode::kFatalError;
}