diff options
author | George Hazan <ghazan@miranda.im> | 2022-01-10 18:12:15 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-01-10 18:12:15 +0300 |
commit | dcaae5dea7a22183576ee6ce3045cacab085a56c (patch) | |
tree | 8b5edf03e7a8c8fa2e3d74ab54de2932fb6566d8 /plugins/PluginUpdater | |
parent | 26b0b0cc55d29b549bd364e622e95c55ef6ea24d (diff) |
PU::IsMirandaFolderWritable - core function to detect if need to draw a shield on buttons that require escalation
Diffstat (limited to 'plugins/PluginUpdater')
-rw-r--r-- | plugins/PluginUpdater/src/DlgListNew.cpp | 17 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/DlgUpdate.cpp | 18 |
2 files changed, 4 insertions, 31 deletions
diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp index 8dcbc35592..bcc050163f 100644 --- a/plugins/PluginUpdater/src/DlgListNew.cpp +++ b/plugins/PluginUpdater/src/DlgListNew.cpp @@ -129,21 +129,8 @@ public: ImageList_AddIconFromIconLib(hIml, IDI_INFO);
m_list.SetImageList(hIml, LVSIL_SMALL);
- if (IsWinVer7Plus()) {
- TFileName szPath;
- GetModuleFileNameW(nullptr, szPath, _countof(szPath));
- wchar_t *ext = wcsrchr(szPath, '.');
- if (ext != nullptr)
- *ext = '\0';
- wcscat(szPath, L".test");
- HANDLE hFile = CreateFileW(szPath, GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
- if (hFile == INVALID_HANDLE_VALUE)
- Button_SetElevationRequiredState(GetDlgItem(m_hwnd, IDOK), !PU::IsProcessElevated());
- else {
- CloseHandle(hFile);
- DeleteFile(szPath);
- }
- }
+ if (!PU::IsMirandaFolderWritable())
+ Button_SetElevationRequiredState(GetDlgItem(m_hwnd, IDOK), !PU::IsProcessElevated());
//////////////////////////////////////////////////////////////////////////////////////
LVCOLUMN lvc = { 0 };
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index baa2d0e90d..90a5a3be48 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -203,22 +203,8 @@ public: Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_MENU));
- if (IsWinVerVistaPlus()) {
- TFileName wszPath;
- GetModuleFileName(nullptr, wszPath, _countof(wszPath));
- wchar_t *ext = wcsrchr(wszPath, '.');
- if (ext != nullptr)
- *ext = '\0';
- wcscat(wszPath, L".test");
- HANDLE hFile = CreateFileW(wszPath, GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
- if (hFile == INVALID_HANDLE_VALUE)
- // Running Windows Vista or later (major version >= 6).
- Button_SetElevationRequiredState(btnOk.GetHwnd(), !PU::IsProcessElevated());
- else {
- CloseHandle(hFile);
- DeleteFileW(wszPath);
- }
- }
+ if (!PU::IsMirandaFolderWritable())
+ Button_SetElevationRequiredState(btnOk.GetHwnd(), !PU::IsProcessElevated());
// Initialize the LVCOLUMN structure.
// The mask specifies that the format, width, text, and
|