diff options
| author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2024-05-14 00:00:00 +0000 |
|---|---|---|
| committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2024-05-15 23:55:04 +0500 |
| commit | fc662341e6f85da78ada0e443f6116b978f79f22 (patch) | |
| tree | 1be1cc402a7a9cbc18d4eeea6b141354c2d559e3 /C/Util/7zipUninstall | |
| parent | 5b39dc76f1bc82f941d5c800ab9f34407a06b53a (diff) | |
| download | 7zip-24.05.tar.gz 7zip-24.05.tar.bz2 7zip-24.05.zip | |
24.0524.05
Diffstat (limited to 'C/Util/7zipUninstall')
| -rw-r--r-- | C/Util/7zipUninstall/7zipUninstall.c | 75 | ||||
| -rw-r--r-- | C/Util/7zipUninstall/Precomp.h | 13 | ||||
| -rw-r--r-- | C/Util/7zipUninstall/resource.rc | 5 |
3 files changed, 55 insertions, 38 deletions
diff --git a/C/Util/7zipUninstall/7zipUninstall.c b/C/Util/7zipUninstall/7zipUninstall.c index 8bc18b3..e7051e2 100644 --- a/C/Util/7zipUninstall/7zipUninstall.c +++ b/C/Util/7zipUninstall/7zipUninstall.c | |||
| @@ -1,10 +1,11 @@ | |||
| 1 | /* 7zipUninstall.c - 7-Zip Uninstaller | 1 | /* 7zipUninstall.c - 7-Zip Uninstaller |
| 2 | 2022-07-15 : Igor Pavlov : Public domain */ | 2 | 2024-03-21 : Igor Pavlov : Public domain */ |
| 3 | 3 | ||
| 4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
| 5 | 5 | ||
| 6 | // #define SZ_ERROR_ABORT 100 | 6 | // #define SZ_ERROR_ABORT 100 |
| 7 | 7 | ||
| 8 | #include "../../7zTypes.h" | ||
| 8 | #include "../../7zWindows.h" | 9 | #include "../../7zWindows.h" |
| 9 | 10 | ||
| 10 | #if defined(_MSC_VER) && _MSC_VER < 1600 | 11 | #if defined(_MSC_VER) && _MSC_VER < 1600 |
| @@ -31,16 +32,7 @@ typedef enum { | |||
| 31 | 32 | ||
| 32 | #include "resource.h" | 33 | #include "resource.h" |
| 33 | 34 | ||
| 34 | #if (defined(__GNUC__) && (__GNUC__ >= 8)) || defined(__clang__) | ||
| 35 | // #pragma GCC diagnostic ignored "-Wcast-function-type" | ||
| 36 | #endif | ||
| 37 | 35 | ||
| 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 | 36 | ||
| 45 | 37 | ||
| 46 | #define LLL_(quote) L##quote | 38 | #define LLL_(quote) L##quote |
| @@ -101,11 +93,13 @@ static LPCWSTR const k_Reg_Path32 = L"Path" | |||
| 101 | #define k_Reg_WOW_Flag 0 | 93 | #define k_Reg_WOW_Flag 0 |
| 102 | #endif | 94 | #endif |
| 103 | 95 | ||
| 96 | #ifdef USE_7ZIP_32_DLL | ||
| 104 | #ifdef _WIN64 | 97 | #ifdef _WIN64 |
| 105 | #define k_Reg_WOW_Flag_32 KEY_WOW64_32KEY | 98 | #define k_Reg_WOW_Flag_32 KEY_WOW64_32KEY |
| 106 | #else | 99 | #else |
| 107 | #define k_Reg_WOW_Flag_32 0 | 100 | #define k_Reg_WOW_Flag_32 0 |
| 108 | #endif | 101 | #endif |
| 102 | #endif | ||
| 109 | 103 | ||
| 110 | #define k_7zip_CLSID L"{23170F69-40C1-278A-1000-000100020000}" | 104 | #define k_7zip_CLSID L"{23170F69-40C1-278A-1000-000100020000}" |
| 111 | 105 | ||
| @@ -124,9 +118,19 @@ static HWND g_Path_HWND; | |||
| 124 | static HWND g_InfoLine_HWND; | 118 | static HWND g_InfoLine_HWND; |
| 125 | static HWND g_Progress_HWND; | 119 | static HWND g_Progress_HWND; |
| 126 | 120 | ||
| 127 | // WINADVAPI | 121 | // RegDeleteKeyExW is supported starting from win2003sp1/xp-pro-x64 |
| 122 | // Z7_WIN32_WINNT_MIN < 0x0600 // Vista | ||
| 123 | #if !defined(Z7_WIN32_WINNT_MIN) \ | ||
| 124 | || Z7_WIN32_WINNT_MIN < 0x0502 /* < win2003 */ \ | ||
| 125 | || Z7_WIN32_WINNT_MIN == 0x0502 && !defined(_M_AMD64) | ||
| 126 | #define Z7_USE_DYN_RegDeleteKeyExW | ||
| 127 | #endif | ||
| 128 | |||
| 129 | #ifdef Z7_USE_DYN_RegDeleteKeyExW | ||
| 130 | Z7_DIAGNOSTIC_IGNORE_CAST_FUNCTION | ||
| 128 | typedef LONG (APIENTRY *Func_RegDeleteKeyExW)(HKEY hKey, LPCWSTR lpSubKey, REGSAM samDesired, DWORD Reserved); | 131 | typedef LONG (APIENTRY *Func_RegDeleteKeyExW)(HKEY hKey, LPCWSTR lpSubKey, REGSAM samDesired, DWORD Reserved); |
| 129 | static Func_RegDeleteKeyExW func_RegDeleteKeyExW; | 132 | static Func_RegDeleteKeyExW func_RegDeleteKeyExW; |
| 133 | #endif | ||
| 130 | 134 | ||
| 131 | static WCHAR cmd[MAX_PATH + 4]; | 135 | static WCHAR cmd[MAX_PATH + 4]; |
| 132 | static WCHAR cmdError[MAX_PATH + 4]; | 136 | static WCHAR cmdError[MAX_PATH + 4]; |
| @@ -247,13 +251,18 @@ static LONG MyRegistry_OpenKey_ReadWrite(HKEY parentKey, LPCWSTR name, HKEY *des | |||
| 247 | 251 | ||
| 248 | static LONG MyRegistry_DeleteKey(HKEY parentKey, LPCWSTR name) | 252 | static LONG MyRegistry_DeleteKey(HKEY parentKey, LPCWSTR name) |
| 249 | { | 253 | { |
| 250 | #if k_Reg_WOW_Flag != 0 | 254 | #if k_Reg_WOW_Flag != 0 |
| 251 | if (func_RegDeleteKeyExW) | 255 | #ifdef Z7_USE_DYN_RegDeleteKeyExW |
| 252 | return func_RegDeleteKeyExW(parentKey, name, k_Reg_WOW_Flag, 0); | 256 | if (!func_RegDeleteKeyExW) |
| 253 | return E_FAIL; | 257 | return E_FAIL; |
| 254 | #else | 258 | return func_RegDeleteKeyExW |
| 259 | #else | ||
| 260 | return RegDeleteKeyExW | ||
| 261 | #endif | ||
| 262 | (parentKey, name, k_Reg_WOW_Flag, 0); | ||
| 263 | #else | ||
| 255 | return RegDeleteKeyW(parentKey, name); | 264 | return RegDeleteKeyW(parentKey, name); |
| 256 | #endif | 265 | #endif |
| 257 | } | 266 | } |
| 258 | 267 | ||
| 259 | #ifdef USE_7ZIP_32_DLL | 268 | #ifdef USE_7ZIP_32_DLL |
| @@ -278,13 +287,18 @@ static LONG MyRegistry_OpenKey_ReadWrite_32(HKEY parentKey, LPCWSTR name, HKEY * | |||
| 278 | 287 | ||
| 279 | static LONG MyRegistry_DeleteKey_32(HKEY parentKey, LPCWSTR name) | 288 | static LONG MyRegistry_DeleteKey_32(HKEY parentKey, LPCWSTR name) |
| 280 | { | 289 | { |
| 281 | #if k_Reg_WOW_Flag_32 != 0 | 290 | #if k_Reg_WOW_Flag_32 != 0 |
| 282 | if (func_RegDeleteKeyExW) | 291 | #ifdef Z7_USE_DYN_RegDeleteKeyExW |
| 283 | return func_RegDeleteKeyExW(parentKey, name, k_Reg_WOW_Flag_32, 0); | 292 | if (!func_RegDeleteKeyExW) |
| 284 | return E_FAIL; | 293 | return E_FAIL; |
| 285 | #else | 294 | return func_RegDeleteKeyExW |
| 295 | #else | ||
| 296 | return RegDeleteKeyExW | ||
| 297 | #endif | ||
| 298 | (parentKey, name, k_Reg_WOW_Flag_32, 0); | ||
| 299 | #else | ||
| 286 | return RegDeleteKeyW(parentKey, name); | 300 | return RegDeleteKeyW(parentKey, name); |
| 287 | #endif | 301 | #endif |
| 288 | } | 302 | } |
| 289 | 303 | ||
| 290 | #endif | 304 | #endif |
| @@ -930,14 +944,17 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 930 | UNUSED_VAR(lpCmdLine) | 944 | UNUSED_VAR(lpCmdLine) |
| 931 | UNUSED_VAR(nCmdShow) | 945 | UNUSED_VAR(nCmdShow) |
| 932 | 946 | ||
| 933 | #ifndef UNDER_CE | 947 | #ifndef UNDER_CE |
| 934 | CoInitialize(NULL); | 948 | CoInitialize(NULL); |
| 935 | #endif | 949 | #endif |
| 936 | 950 | ||
| 937 | #ifndef UNDER_CE | 951 | #ifndef UNDER_CE |
| 938 | func_RegDeleteKeyExW = (Func_RegDeleteKeyExW) MY_CAST_FUNC | 952 | #ifdef Z7_USE_DYN_RegDeleteKeyExW |
| 939 | GetProcAddress(GetModuleHandleW(L"advapi32.dll"), "RegDeleteKeyExW"); | 953 | func_RegDeleteKeyExW = |
| 940 | #endif | 954 | (Func_RegDeleteKeyExW) Z7_CAST_FUNC_C GetProcAddress(GetModuleHandleW(L"advapi32.dll"), |
| 955 | "RegDeleteKeyExW"); | ||
| 956 | #endif | ||
| 957 | #endif | ||
| 941 | 958 | ||
| 942 | { | 959 | { |
| 943 | const wchar_t *s = GetCommandLineW(); | 960 | const wchar_t *s = GetCommandLineW(); |
diff --git a/C/Util/7zipUninstall/Precomp.h b/C/Util/7zipUninstall/Precomp.h index bc8fa21..13a41ef 100644 --- a/C/Util/7zipUninstall/Precomp.h +++ b/C/Util/7zipUninstall/Precomp.h | |||
| @@ -1,14 +1,13 @@ | |||
| 1 | /* Precomp.h -- StdAfx | 1 | /* Precomp.h -- Precomp |
| 2 | 2023-03-04 : Igor Pavlov : Public domain */ | 2 | 2024-01-23 : Igor Pavlov : Public domain */ |
| 3 | 3 | ||
| 4 | #ifndef ZIP7_INC_PRECOMP_H | 4 | // #ifndef ZIP7_INC_PRECOMP_LOC_H |
| 5 | #define ZIP7_INC_PRECOMP_H | 5 | // #define ZIP7_INC_PRECOMP_LOC_H |
| 6 | 6 | ||
| 7 | #if defined(_MSC_VER) && _MSC_VER >= 1800 | 7 | #if defined(_MSC_VER) && _MSC_VER >= 1800 |
| 8 | #pragma warning(disable : 4464) // relative include path contains '..' | 8 | #pragma warning(disable : 4464) // relative include path contains '..' |
| 9 | #endif | 9 | #endif |
| 10 | 10 | ||
| 11 | #include "../../Compiler.h" | 11 | #include "../../Precomp.h" |
| 12 | #include "../../7zTypes.h" | ||
| 13 | 12 | ||
| 14 | #endif | 13 | // #endif |
diff --git a/C/Util/7zipUninstall/resource.rc b/C/Util/7zipUninstall/resource.rc index 00bdcc0..79400c6 100644 --- a/C/Util/7zipUninstall/resource.rc +++ b/C/Util/7zipUninstall/resource.rc | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #include <winnt.h> | 1 | #include <windows.h> |
| 2 | #include <WinUser.h> | 2 | // #include <winnt.h> |
| 3 | // #include <WinUser.h> | ||
| 3 | #include <CommCtrl.h> | 4 | #include <CommCtrl.h> |
| 4 | 5 | ||
| 5 | #define USE_COPYRIGHT_CR | 6 | #define USE_COPYRIGHT_CR |
