diff options
| author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-06-21 00:00:00 +0000 |
|---|---|---|
| committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-12-17 14:59:19 +0500 |
| commit | 5b39dc76f1bc82f941d5c800ab9f34407a06b53a (patch) | |
| tree | fe5e17420300b715021a76328444088d32047963 /C/Util/7zipUninstall | |
| parent | 93be7d4abfd4233228f58ee1fbbcd76d91be66a4 (diff) | |
| download | 7zip-23.01.tar.gz 7zip-23.01.tar.bz2 7zip-23.01.zip | |
23.0123.01
Diffstat (limited to 'C/Util/7zipUninstall')
| -rw-r--r-- | C/Util/7zipUninstall/7zipUninstall.c | 128 | ||||
| -rw-r--r-- | C/Util/7zipUninstall/7zipUninstall.dsp | 8 | ||||
| -rw-r--r-- | C/Util/7zipUninstall/Precomp.h | 11 | ||||
| -rw-r--r-- | C/Util/7zipUninstall/makefile | 4 |
4 files changed, 96 insertions, 55 deletions
diff --git a/C/Util/7zipUninstall/7zipUninstall.c b/C/Util/7zipUninstall/7zipUninstall.c index c8e8a89..8bc18b3 100644 --- a/C/Util/7zipUninstall/7zipUninstall.c +++ b/C/Util/7zipUninstall/7zipUninstall.c | |||
| @@ -3,40 +3,64 @@ | |||
| 3 | 3 | ||
| 4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
| 5 | 5 | ||
| 6 | #ifdef _MSC_VER | 6 | // #define SZ_ERROR_ABORT 100 |
| 7 | |||
| 8 | #include "../../7zWindows.h" | ||
| 9 | |||
| 10 | #if defined(_MSC_VER) && _MSC_VER < 1600 | ||
| 7 | #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union | 11 | #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union |
| 8 | #pragma warning(disable : 4011) // vs2010: identifier truncated to _CRT_SECURE_CPP_OVERLOAD_SECURE | ||
| 9 | #endif | 12 | #endif |
| 10 | 13 | ||
| 11 | // #define SZ_ERROR_ABORT 100 | 14 | #ifdef Z7_OLD_WIN_SDK |
| 12 | 15 | struct IShellView; | |
| 13 | #include <windows.h> | 16 | #define SHFOLDERAPI EXTERN_C DECLSPEC_IMPORT HRESULT STDAPICALLTYPE |
| 17 | SHFOLDERAPI SHGetFolderPathW(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath); | ||
| 18 | #define BIF_NEWDIALOGSTYLE 0x0040 // Use the new dialog layout with the ability to resize | ||
| 19 | typedef enum { | ||
| 20 | SHGFP_TYPE_CURRENT = 0, // current value for user, verify it exists | ||
| 21 | SHGFP_TYPE_DEFAULT = 1, // default value, may not exist | ||
| 22 | } SHGFP_TYPE; | ||
| 23 | #endif | ||
| 24 | #if defined(__MINGW32__) || defined(__MINGW64__) | ||
| 25 | #include <shlobj.h> | ||
| 26 | #else | ||
| 14 | #include <ShlObj.h> | 27 | #include <ShlObj.h> |
| 28 | #endif | ||
| 15 | 29 | ||
| 16 | #include "../../7zVersion.h" | 30 | #include "../../7zVersion.h" |
| 17 | 31 | ||
| 18 | #include "resource.h" | 32 | #include "resource.h" |
| 19 | 33 | ||
| 20 | #if defined(__GNUC__) && (__GNUC__ >= 8) | 34 | #if (defined(__GNUC__) && (__GNUC__ >= 8)) || defined(__clang__) |
| 21 | #pragma GCC diagnostic ignored "-Wcast-function-type" | 35 | // #pragma GCC diagnostic ignored "-Wcast-function-type" |
| 22 | #endif | 36 | #endif |
| 23 | 37 | ||
| 38 | #if defined(_MSC_VER) && _MSC_VER > 1920 | ||
| 39 | #define MY_CAST_FUNC (void *) | ||
| 40 | // #pragma warning(disable : 4191) // 'type cast': unsafe conversion from 'FARPROC' to 'void (__cdecl *)()' | ||
| 41 | #else | ||
| 42 | #define MY_CAST_FUNC | ||
| 43 | #endif | ||
| 44 | |||
| 45 | |||
| 24 | #define LLL_(quote) L##quote | 46 | #define LLL_(quote) L##quote |
| 25 | #define LLL(quote) LLL_(quote) | 47 | #define LLL(quote) LLL_(quote) |
| 26 | 48 | ||
| 27 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) | 49 | #define wcscat lstrcatW |
| 50 | #define wcslen (size_t)lstrlenW | ||
| 51 | #define wcscpy lstrcpyW | ||
| 28 | 52 | ||
| 29 | // static LPCWSTR const k_7zip = L"7-Zip"; | 53 | // static LPCWSTR const k_7zip = L"7-Zip"; |
| 30 | 54 | ||
| 31 | // #define _64BIT_INSTALLER 1 | 55 | // #define Z7_64BIT_INSTALLER 1 |
| 32 | 56 | ||
| 33 | #ifdef _WIN64 | 57 | #ifdef _WIN64 |
| 34 | #define _64BIT_INSTALLER 1 | 58 | #define Z7_64BIT_INSTALLER 1 |
| 35 | #endif | 59 | #endif |
| 36 | 60 | ||
| 37 | #define k_7zip_with_Ver_base L"7-Zip " LLL(MY_VERSION) | 61 | #define k_7zip_with_Ver_base L"7-Zip " LLL(MY_VERSION) |
| 38 | 62 | ||
| 39 | #ifdef _64BIT_INSTALLER | 63 | #ifdef Z7_64BIT_INSTALLER |
| 40 | 64 | ||
| 41 | // #define USE_7ZIP_32_DLL | 65 | // #define USE_7ZIP_32_DLL |
| 42 | 66 | ||
| @@ -64,14 +88,14 @@ static LPCWSTR const k_Reg_Software_7zip = L"Software\\7-Zip"; | |||
| 64 | static LPCWSTR const k_Reg_Path = L"Path"; | 88 | static LPCWSTR const k_Reg_Path = L"Path"; |
| 65 | 89 | ||
| 66 | static LPCWSTR const k_Reg_Path32 = L"Path" | 90 | static LPCWSTR const k_Reg_Path32 = L"Path" |
| 67 | #ifdef _64BIT_INSTALLER | 91 | #ifdef Z7_64BIT_INSTALLER |
| 68 | L"64" | 92 | L"64" |
| 69 | #else | 93 | #else |
| 70 | L"32" | 94 | L"32" |
| 71 | #endif | 95 | #endif |
| 72 | ; | 96 | ; |
| 73 | 97 | ||
| 74 | #if defined(_64BIT_INSTALLER) && !defined(_WIN64) | 98 | #if defined(Z7_64BIT_INSTALLER) && !defined(_WIN64) |
| 75 | #define k_Reg_WOW_Flag KEY_WOW64_64KEY | 99 | #define k_Reg_WOW_Flag KEY_WOW64_64KEY |
| 76 | #else | 100 | #else |
| 77 | #define k_Reg_WOW_Flag 0 | 101 | #define k_Reg_WOW_Flag 0 |
| @@ -116,14 +140,14 @@ static WCHAR copyPath[MAX_PATH * 2 + 40]; | |||
| 116 | 140 | ||
| 117 | static LPCWSTR const kUninstallExe = L"Uninstall.exe"; | 141 | static LPCWSTR const kUninstallExe = L"Uninstall.exe"; |
| 118 | 142 | ||
| 119 | #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c))) | 143 | #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c))) |
| 120 | 144 | ||
| 121 | 145 | ||
| 122 | static void CpyAscii(wchar_t *dest, const char *s) | 146 | static void CpyAscii(wchar_t *dest, const char *s) |
| 123 | { | 147 | { |
| 124 | for (;;) | 148 | for (;;) |
| 125 | { | 149 | { |
| 126 | Byte b = (Byte)*s++; | 150 | const Byte b = (Byte)*s++; |
| 127 | *dest++ = b; | 151 | *dest++ = b; |
| 128 | if (b == 0) | 152 | if (b == 0) |
| 129 | return; | 153 | return; |
| @@ -173,7 +197,7 @@ static BoolInt IsString1PrefixedByString2_NoCase(const wchar_t *s1, const wchar_ | |||
| 173 | for (;;) | 197 | for (;;) |
| 174 | { | 198 | { |
| 175 | wchar_t c1; | 199 | wchar_t c1; |
| 176 | wchar_t c2 = *s2++; | 200 | const wchar_t c2 = *s2++; |
| 177 | if (c2 == 0) | 201 | if (c2 == 0) |
| 178 | return True; | 202 | return True; |
| 179 | c1 = *s1++; | 203 | c1 = *s1++; |
| @@ -184,7 +208,7 @@ static BoolInt IsString1PrefixedByString2_NoCase(const wchar_t *s1, const wchar_ | |||
| 184 | 208 | ||
| 185 | static void NormalizePrefix(WCHAR *s) | 209 | static void NormalizePrefix(WCHAR *s) |
| 186 | { | 210 | { |
| 187 | size_t len = wcslen(s); | 211 | const size_t len = wcslen(s); |
| 188 | if (len != 0) | 212 | if (len != 0) |
| 189 | if (s[len - 1] != WCHAR_PATH_SEPARATOR) | 213 | if (s[len - 1] != WCHAR_PATH_SEPARATOR) |
| 190 | { | 214 | { |
| @@ -197,7 +221,7 @@ static int MyRegistry_QueryString(HKEY hKey, LPCWSTR name, LPWSTR dest) | |||
| 197 | { | 221 | { |
| 198 | DWORD cnt = MAX_PATH * sizeof(name[0]); | 222 | DWORD cnt = MAX_PATH * sizeof(name[0]); |
| 199 | DWORD type = 0; | 223 | DWORD type = 0; |
| 200 | LONG res = RegQueryValueExW(hKey, name, NULL, &type, (LPBYTE)dest, (DWORD *)&cnt); | 224 | const LONG res = RegQueryValueExW(hKey, name, NULL, &type, (LPBYTE)dest, &cnt); |
| 201 | if (type != REG_SZ) | 225 | if (type != REG_SZ) |
| 202 | return False; | 226 | return False; |
| 203 | return res == ERROR_SUCCESS; | 227 | return res == ERROR_SUCCESS; |
| @@ -206,11 +230,11 @@ static int MyRegistry_QueryString(HKEY hKey, LPCWSTR name, LPWSTR dest) | |||
| 206 | static int MyRegistry_QueryString2(HKEY hKey, LPCWSTR keyName, LPCWSTR valName, LPWSTR dest) | 230 | static int MyRegistry_QueryString2(HKEY hKey, LPCWSTR keyName, LPCWSTR valName, LPWSTR dest) |
| 207 | { | 231 | { |
| 208 | HKEY key = 0; | 232 | HKEY key = 0; |
| 209 | LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag, &key); | 233 | const LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag, &key); |
| 210 | if (res != ERROR_SUCCESS) | 234 | if (res != ERROR_SUCCESS) |
| 211 | return False; | 235 | return False; |
| 212 | { | 236 | { |
| 213 | BoolInt res2 = MyRegistry_QueryString(key, valName, dest); | 237 | const BoolInt res2 = MyRegistry_QueryString(key, valName, dest); |
| 214 | RegCloseKey(key); | 238 | RegCloseKey(key); |
| 215 | return res2; | 239 | return res2; |
| 216 | } | 240 | } |
| @@ -237,11 +261,11 @@ static LONG MyRegistry_DeleteKey(HKEY parentKey, LPCWSTR name) | |||
| 237 | static int MyRegistry_QueryString2_32(HKEY hKey, LPCWSTR keyName, LPCWSTR valName, LPWSTR dest) | 261 | static int MyRegistry_QueryString2_32(HKEY hKey, LPCWSTR keyName, LPCWSTR valName, LPWSTR dest) |
| 238 | { | 262 | { |
| 239 | HKEY key = 0; | 263 | HKEY key = 0; |
| 240 | LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag_32, &key); | 264 | const LONG res = RegOpenKeyExW(hKey, keyName, 0, KEY_READ | k_Reg_WOW_Flag_32, &key); |
| 241 | if (res != ERROR_SUCCESS) | 265 | if (res != ERROR_SUCCESS) |
| 242 | return False; | 266 | return False; |
| 243 | { | 267 | { |
| 244 | BoolInt res2 = MyRegistry_QueryString(key, valName, dest); | 268 | const BoolInt res2 = MyRegistry_QueryString(key, valName, dest); |
| 245 | RegCloseKey(key); | 269 | RegCloseKey(key); |
| 246 | return res2; | 270 | return res2; |
| 247 | } | 271 | } |
| @@ -282,7 +306,7 @@ static void MyReg_DeleteVal_Path_if_Equal(HKEY hKey, LPCWSTR name) | |||
| 282 | static void SetRegKey_Path2(HKEY parentKey) | 306 | static void SetRegKey_Path2(HKEY parentKey) |
| 283 | { | 307 | { |
| 284 | HKEY key = 0; | 308 | HKEY key = 0; |
| 285 | LONG res = MyRegistry_OpenKey_ReadWrite(parentKey, k_Reg_Software_7zip, &key); | 309 | const LONG res = MyRegistry_OpenKey_ReadWrite(parentKey, k_Reg_Software_7zip, &key); |
| 286 | if (res == ERROR_SUCCESS) | 310 | if (res == ERROR_SUCCESS) |
| 287 | { | 311 | { |
| 288 | MyReg_DeleteVal_Path_if_Equal(key, k_Reg_Path32); | 312 | MyReg_DeleteVal_Path_if_Equal(key, k_Reg_Path32); |
| @@ -293,7 +317,7 @@ static void SetRegKey_Path2(HKEY parentKey) | |||
| 293 | } | 317 | } |
| 294 | } | 318 | } |
| 295 | 319 | ||
| 296 | static void SetRegKey_Path() | 320 | static void SetRegKey_Path(void) |
| 297 | { | 321 | { |
| 298 | SetRegKey_Path2(HKEY_CURRENT_USER); | 322 | SetRegKey_Path2(HKEY_CURRENT_USER); |
| 299 | SetRegKey_Path2(HKEY_LOCAL_MACHINE); | 323 | SetRegKey_Path2(HKEY_LOCAL_MACHINE); |
| @@ -426,7 +450,7 @@ static BoolInt AreEqual_Path_PrefixName(const wchar_t *s, const wchar_t *prefix, | |||
| 426 | return AreStringsEqual_NoCase(s + wcslen(prefix), name); | 450 | return AreStringsEqual_NoCase(s + wcslen(prefix), name); |
| 427 | } | 451 | } |
| 428 | 452 | ||
| 429 | static void WriteCLSID() | 453 | static void WriteCLSID(void) |
| 430 | { | 454 | { |
| 431 | WCHAR s[MAX_PATH + 30]; | 455 | WCHAR s[MAX_PATH + 30]; |
| 432 | 456 | ||
| @@ -435,14 +459,14 @@ static void WriteCLSID() | |||
| 435 | if (AreEqual_Path_PrefixName(s, path, L"7-zip.dll")) | 459 | if (AreEqual_Path_PrefixName(s, path, L"7-zip.dll")) |
| 436 | { | 460 | { |
| 437 | { | 461 | { |
| 438 | LONG res = MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc); | 462 | const LONG res = MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc); |
| 439 | if (res == ERROR_SUCCESS) | 463 | if (res == ERROR_SUCCESS) |
| 440 | MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip); | 464 | MyRegistry_DeleteKey(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip); |
| 441 | } | 465 | } |
| 442 | 466 | ||
| 443 | { | 467 | { |
| 444 | unsigned i; | 468 | unsigned i; |
| 445 | for (i = 0; i < ARRAY_SIZE(k_ShellEx_Items); i++) | 469 | for (i = 0; i < Z7_ARRAY_SIZE(k_ShellEx_Items); i++) |
| 446 | { | 470 | { |
| 447 | WCHAR destPath[MAX_PATH]; | 471 | WCHAR destPath[MAX_PATH]; |
| 448 | CpyAscii(destPath, k_ShellEx_Items[i]); | 472 | CpyAscii(destPath, k_ShellEx_Items[i]); |
| @@ -454,7 +478,7 @@ static void WriteCLSID() | |||
| 454 | 478 | ||
| 455 | { | 479 | { |
| 456 | HKEY destKey = 0; | 480 | HKEY destKey = 0; |
| 457 | LONG res = MyRegistry_OpenKey_ReadWrite(HKEY_LOCAL_MACHINE, k_Shell_Approved, &destKey); | 481 | const LONG res = MyRegistry_OpenKey_ReadWrite(HKEY_LOCAL_MACHINE, k_Shell_Approved, &destKey); |
| 458 | if (res == ERROR_SUCCESS) | 482 | if (res == ERROR_SUCCESS) |
| 459 | { | 483 | { |
| 460 | RegDeleteValueW(destKey, k_7zip_CLSID); | 484 | RegDeleteValueW(destKey, k_7zip_CLSID); |
| @@ -472,14 +496,14 @@ static void WriteCLSID() | |||
| 472 | if (AreEqual_Path_PrefixName(s, path, L"7-zip32.dll")) | 496 | if (AreEqual_Path_PrefixName(s, path, L"7-zip32.dll")) |
| 473 | { | 497 | { |
| 474 | { | 498 | { |
| 475 | LONG res = MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc); | 499 | const LONG res = MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip_Inproc); |
| 476 | if (res == ERROR_SUCCESS) | 500 | if (res == ERROR_SUCCESS) |
| 477 | MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip); | 501 | MyRegistry_DeleteKey_32(HKEY_CLASSES_ROOT, k_Reg_CLSID_7zip); |
| 478 | } | 502 | } |
| 479 | 503 | ||
| 480 | { | 504 | { |
| 481 | unsigned i; | 505 | unsigned i; |
| 482 | for (i = 0; i < ARRAY_SIZE(k_ShellEx_Items); i++) | 506 | for (i = 0; i < Z7_ARRAY_SIZE(k_ShellEx_Items); i++) |
| 483 | { | 507 | { |
| 484 | WCHAR destPath[MAX_PATH]; | 508 | WCHAR destPath[MAX_PATH]; |
| 485 | CpyAscii(destPath, k_ShellEx_Items[i]); | 509 | CpyAscii(destPath, k_ShellEx_Items[i]); |
| @@ -491,7 +515,7 @@ static void WriteCLSID() | |||
| 491 | 515 | ||
| 492 | { | 516 | { |
| 493 | HKEY destKey = 0; | 517 | HKEY destKey = 0; |
| 494 | LONG res = MyRegistry_OpenKey_ReadWrite_32(HKEY_LOCAL_MACHINE, k_Shell_Approved, &destKey); | 518 | const LONG res = MyRegistry_OpenKey_ReadWrite_32(HKEY_LOCAL_MACHINE, k_Shell_Approved, &destKey); |
| 495 | if (res == ERROR_SUCCESS) | 519 | if (res == ERROR_SUCCESS) |
| 496 | { | 520 | { |
| 497 | RegDeleteValueW(destKey, k_7zip_CLSID); | 521 | RegDeleteValueW(destKey, k_7zip_CLSID); |
| @@ -526,7 +550,7 @@ static const wchar_t *GetCmdParam(const wchar_t *s) | |||
| 526 | BoolInt quoteMode = False; | 550 | BoolInt quoteMode = False; |
| 527 | for (;; s++) | 551 | for (;; s++) |
| 528 | { | 552 | { |
| 529 | wchar_t c = *s; | 553 | const wchar_t c = *s; |
| 530 | if (c == 0 || (c == L' ' && !quoteMode)) | 554 | if (c == 0 || (c == L' ' && !quoteMode)) |
| 531 | break; | 555 | break; |
| 532 | if (c == L'\"') | 556 | if (c == L'\"') |
| @@ -534,7 +558,7 @@ static const wchar_t *GetCmdParam(const wchar_t *s) | |||
| 534 | quoteMode = !quoteMode; | 558 | quoteMode = !quoteMode; |
| 535 | continue; | 559 | continue; |
| 536 | } | 560 | } |
| 537 | if (pos >= ARRAY_SIZE(cmd) - 1) | 561 | if (pos >= Z7_ARRAY_SIZE(cmd) - 1) |
| 538 | exit(1); | 562 | exit(1); |
| 539 | cmd[pos++] = c; | 563 | cmd[pos++] = c; |
| 540 | } | 564 | } |
| @@ -558,7 +582,7 @@ static void RemoveQuotes(wchar_t *s) | |||
| 558 | } | 582 | } |
| 559 | */ | 583 | */ |
| 560 | 584 | ||
| 561 | static BoolInt DoesFileOrDirExist() | 585 | static BoolInt DoesFileOrDirExist(void) |
| 562 | { | 586 | { |
| 563 | return (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES); | 587 | return (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES); |
| 564 | } | 588 | } |
| @@ -573,7 +597,7 @@ static BOOL RemoveFileAfterReboot2(const WCHAR *s) | |||
| 573 | #endif | 597 | #endif |
| 574 | } | 598 | } |
| 575 | 599 | ||
| 576 | static BOOL RemoveFileAfterReboot() | 600 | static BOOL RemoveFileAfterReboot(void) |
| 577 | { | 601 | { |
| 578 | return RemoveFileAfterReboot2(path); | 602 | return RemoveFileAfterReboot2(path); |
| 579 | } | 603 | } |
| @@ -584,7 +608,7 @@ static BoolInt IsThereSpace(const wchar_t *s) | |||
| 584 | { | 608 | { |
| 585 | for (;;) | 609 | for (;;) |
| 586 | { | 610 | { |
| 587 | wchar_t c = *s++; | 611 | const wchar_t c = *s++; |
| 588 | if (c == 0) | 612 | if (c == 0) |
| 589 | return False; | 613 | return False; |
| 590 | if (c == ' ') | 614 | if (c == ' ') |
| @@ -594,7 +618,7 @@ static BoolInt IsThereSpace(const wchar_t *s) | |||
| 594 | 618 | ||
| 595 | static void AddPathParam(wchar_t *dest, const wchar_t *src) | 619 | static void AddPathParam(wchar_t *dest, const wchar_t *src) |
| 596 | { | 620 | { |
| 597 | BoolInt needQuote = IsThereSpace(src); | 621 | const BoolInt needQuote = IsThereSpace(src); |
| 598 | if (needQuote) | 622 | if (needQuote) |
| 599 | CatAscii(dest, "\""); | 623 | CatAscii(dest, "\""); |
| 600 | wcscat(dest, src); | 624 | wcscat(dest, src); |
| @@ -618,9 +642,9 @@ static BoolInt GetErrorMessage(DWORD errorCode, WCHAR *message) | |||
| 618 | return True; | 642 | return True; |
| 619 | } | 643 | } |
| 620 | 644 | ||
| 621 | static BOOL RemoveDir() | 645 | static BOOL RemoveDir(void) |
| 622 | { | 646 | { |
| 623 | DWORD attrib = GetFileAttributesW(path); | 647 | const DWORD attrib = GetFileAttributesW(path); |
| 624 | if (attrib == INVALID_FILE_ATTRIBUTES) | 648 | if (attrib == INVALID_FILE_ATTRIBUTES) |
| 625 | return TRUE; | 649 | return TRUE; |
| 626 | if (RemoveDirectoryW(path)) | 650 | if (RemoveDirectoryW(path)) |
| @@ -670,7 +694,7 @@ static const char * const k_Names = | |||
| 670 | 694 | ||
| 671 | 695 | ||
| 672 | 696 | ||
| 673 | static int Install() | 697 | static int Install(void) |
| 674 | { | 698 | { |
| 675 | SRes res = SZ_OK; | 699 | SRes res = SZ_OK; |
| 676 | WRes winRes = 0; | 700 | WRes winRes = 0; |
| @@ -724,7 +748,7 @@ static int Install() | |||
| 724 | 748 | ||
| 725 | for (;;) | 749 | for (;;) |
| 726 | { | 750 | { |
| 727 | char c = *curName; | 751 | const char c = *curName; |
| 728 | if (c == 0) | 752 | if (c == 0) |
| 729 | break; | 753 | break; |
| 730 | curName++; | 754 | curName++; |
| @@ -743,7 +767,7 @@ static int Install() | |||
| 743 | SetWindowTextW(g_InfoLine_HWND, temp); | 767 | SetWindowTextW(g_InfoLine_HWND, temp); |
| 744 | 768 | ||
| 745 | { | 769 | { |
| 746 | DWORD attrib = GetFileAttributesW(path); | 770 | const DWORD attrib = GetFileAttributesW(path); |
| 747 | if (attrib == INVALID_FILE_ATTRIBUTES) | 771 | if (attrib == INVALID_FILE_ATTRIBUTES) |
| 748 | continue; | 772 | continue; |
| 749 | if (attrib & FILE_ATTRIBUTE_READONLY) | 773 | if (attrib & FILE_ATTRIBUTE_READONLY) |
| @@ -803,7 +827,7 @@ static int Install() | |||
| 803 | } | 827 | } |
| 804 | 828 | ||
| 805 | 829 | ||
| 806 | static void OnClose() | 830 | static void OnClose(void) |
| 807 | { | 831 | { |
| 808 | if (g_Install_was_Pressed && !g_Finished) | 832 | if (g_Install_was_Pressed && !g_Finished) |
| 809 | { | 833 | { |
| @@ -817,7 +841,13 @@ static void OnClose() | |||
| 817 | g_HWND = NULL; | 841 | g_HWND = NULL; |
| 818 | } | 842 | } |
| 819 | 843 | ||
| 820 | static INT_PTR CALLBACK MyDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | 844 | static |
| 845 | #ifdef Z7_OLD_WIN_SDK | ||
| 846 | BOOL | ||
| 847 | #else | ||
| 848 | INT_PTR | ||
| 849 | #endif | ||
| 850 | CALLBACK MyDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | ||
| 821 | { | 851 | { |
| 822 | UNUSED_VAR(lParam) | 852 | UNUSED_VAR(lParam) |
| 823 | 853 | ||
| @@ -905,7 +935,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 905 | #endif | 935 | #endif |
| 906 | 936 | ||
| 907 | #ifndef UNDER_CE | 937 | #ifndef UNDER_CE |
| 908 | func_RegDeleteKeyExW = (Func_RegDeleteKeyExW) | 938 | func_RegDeleteKeyExW = (Func_RegDeleteKeyExW) MY_CAST_FUNC |
| 909 | GetProcAddress(GetModuleHandleW(L"advapi32.dll"), "RegDeleteKeyExW"); | 939 | GetProcAddress(GetModuleHandleW(L"advapi32.dll"), "RegDeleteKeyExW"); |
| 910 | #endif | 940 | #endif |
| 911 | 941 | ||
| @@ -976,7 +1006,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 976 | 1006 | ||
| 977 | { | 1007 | { |
| 978 | wchar_t *name; | 1008 | wchar_t *name; |
| 979 | DWORD len = GetModuleFileNameW(NULL, modulePath, MAX_PATH); | 1009 | const DWORD len = GetModuleFileNameW(NULL, modulePath, MAX_PATH); |
| 980 | if (len == 0 || len > MAX_PATH) | 1010 | if (len == 0 || len > MAX_PATH) |
| 981 | return 1; | 1011 | return 1; |
| 982 | 1012 | ||
| @@ -987,7 +1017,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 987 | wchar_t *s = modulePrefix; | 1017 | wchar_t *s = modulePrefix; |
| 988 | for (;;) | 1018 | for (;;) |
| 989 | { | 1019 | { |
| 990 | wchar_t c = *s++; | 1020 | const wchar_t c = *s++; |
| 991 | if (c == 0) | 1021 | if (c == 0) |
| 992 | break; | 1022 | break; |
| 993 | if (c == WCHAR_PATH_SEPARATOR) | 1023 | if (c == WCHAR_PATH_SEPARATOR) |
| @@ -1037,7 +1067,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 1037 | unsigned k; | 1067 | unsigned k; |
| 1038 | for (k = 0; k < 8; k++) | 1068 | for (k = 0; k < 8; k++) |
| 1039 | { | 1069 | { |
| 1040 | unsigned t = value & 0xF; | 1070 | const unsigned t = value & 0xF; |
| 1041 | value >>= 4; | 1071 | value >>= 4; |
| 1042 | s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10))); | 1072 | s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10))); |
| 1043 | } | 1073 | } |
| @@ -1134,7 +1164,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 1134 | return 1; | 1164 | return 1; |
| 1135 | 1165 | ||
| 1136 | { | 1166 | { |
| 1137 | HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON)); | 1167 | const HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON)); |
| 1138 | // SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon); | 1168 | // SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon); |
| 1139 | SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon); | 1169 | SendMessage(g_HWND, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon); |
| 1140 | } | 1170 | } |
diff --git a/C/Util/7zipUninstall/7zipUninstall.dsp b/C/Util/7zipUninstall/7zipUninstall.dsp index cc7b6b6..bb7473f 100644 --- a/C/Util/7zipUninstall/7zipUninstall.dsp +++ b/C/Util/7zipUninstall/7zipUninstall.dsp | |||
| @@ -104,6 +104,14 @@ SOURCE=..\..\7zVersion.h | |||
| 104 | # PROP Default_Filter "" | 104 | # PROP Default_Filter "" |
| 105 | # Begin Source File | 105 | # Begin Source File |
| 106 | 106 | ||
| 107 | SOURCE=..\..\7zWindows.h | ||
| 108 | # End Source File | ||
| 109 | # Begin Source File | ||
| 110 | |||
| 111 | SOURCE=..\..\Compiler.h | ||
| 112 | # End Source File | ||
| 113 | # Begin Source File | ||
| 114 | |||
| 107 | SOURCE=.\Precomp.c | 115 | SOURCE=.\Precomp.c |
| 108 | # ADD CPP /Yc"Precomp.h" | 116 | # ADD CPP /Yc"Precomp.h" |
| 109 | # End Source File | 117 | # End Source File |
diff --git a/C/Util/7zipUninstall/Precomp.h b/C/Util/7zipUninstall/Precomp.h index 4c90d47..bc8fa21 100644 --- a/C/Util/7zipUninstall/Precomp.h +++ b/C/Util/7zipUninstall/Precomp.h | |||
| @@ -1,11 +1,14 @@ | |||
| 1 | /* Precomp.h -- StdAfx | 1 | /* Precomp.h -- StdAfx |
| 2 | 2015-05-24 : Igor Pavlov : Public domain */ | 2 | 2023-03-04 : Igor Pavlov : Public domain */ |
| 3 | 3 | ||
| 4 | #ifndef __7Z_PRECOMP_H | 4 | #ifndef ZIP7_INC_PRECOMP_H |
| 5 | #define __7Z_PRECOMP_H | 5 | #define ZIP7_INC_PRECOMP_H |
| 6 | 6 | ||
| 7 | #include "../../Compiler.h" | 7 | #if defined(_MSC_VER) && _MSC_VER >= 1800 |
| 8 | #pragma warning(disable : 4464) // relative include path contains '..' | ||
| 9 | #endif | ||
| 8 | 10 | ||
| 11 | #include "../../Compiler.h" | ||
| 9 | #include "../../7zTypes.h" | 12 | #include "../../7zTypes.h" |
| 10 | 13 | ||
| 11 | #endif | 14 | #endif |
diff --git a/C/Util/7zipUninstall/makefile b/C/Util/7zipUninstall/makefile index 60c2fe2..9d8aafc 100644 --- a/C/Util/7zipUninstall/makefile +++ b/C/Util/7zipUninstall/makefile | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | PROG = 7zipUninstall.exe | 1 | PROG = 7zipUninstall.exe |
| 2 | MY_FIXED = 1 | 2 | MY_FIXED = 1 |
| 3 | 3 | ||
| 4 | !IFDEF _64BIT_INSTALLER | 4 | !IFDEF Z7_64BIT_INSTALLER |
| 5 | CFLAGS = $(CFLAGS) -D_64BIT_INSTALLER | 5 | CFLAGS = $(CFLAGS) -DZ7_64BIT_INSTALLER |
| 6 | !ENDIF | 6 | !ENDIF |
| 7 | 7 | ||
| 8 | MAIN_OBJS = \ | 8 | MAIN_OBJS = \ |
