From f4f91f87f7a95733351f743180089d51b37f66b9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 29 Oct 2020 19:30:20 +0300 Subject: fixes #2572 (Miranda cannot delete /Program Files/Miranda/autoexec_blabla.ini if running not as admin) --- src/mir_app/src/db_ini.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/mir_app') diff --git a/src/mir_app/src/db_ini.cpp b/src/mir_app/src/db_ini.cpp index d78854af2c..a3796910a0 100644 --- a/src/mir_app/src/db_ini.cpp +++ b/src/mir_app/src/db_ini.cpp @@ -28,6 +28,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static bool bModuleInitialized = false; static HANDLE hIniChangeNotification; +static void MyDeleteFile(const wchar_t *pwszFileName) +{ + if (PU::PrepareEscalation()) + PU::SafeDeleteFile(pwszFileName); +} + ////////////////////////////////////////////////////// class CInstallIniDlg : public CDlgBase @@ -205,7 +211,7 @@ protected: void Delete_OnClick(CCtrlBase*) { ptrW szIniPath(m_iniPath.GetText()); - DeleteFile(szIniPath); + MyDeleteFile(szIniPath); Close(); } @@ -540,12 +546,12 @@ static void DoAutoExec(void) ProcessIniFile(szIniPath, szSafeSections, szUnsafeSections, secur, secFN); if (secFN) - DeleteFile(szIniPath); + MyDeleteFile(szIniPath); else { wchar_t szOnCompletion[8]; Profile_GetSetting(L"AutoExec/OnCompletion", szOnCompletion, L"recycle"); if (!mir_wstrcmpi(szOnCompletion, L"delete")) - DeleteFile(szIniPath); + MyDeleteFile(szIniPath); else if (!mir_wstrcmpi(szOnCompletion, L"recycle")) { DeleteDirectoryTreeW(szIniPath, true); } -- cgit v1.2.3