summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-10-29 19:30:20 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-10-29 19:30:20 +0300
commitf4f91f87f7a95733351f743180089d51b37f66b9 (patch)
tree73eb96600a3cdc293ab154737d033f8d3212b102
parent74e691804c25c6174cb619d21b19fb5dc94afa22 (diff)
fixes #2572 (Miranda cannot delete /Program Files/Miranda/autoexec_blabla.ini if running not as admin)
-rw-r--r--src/mir_app/src/db_ini.cpp12
1 files changed, 9 insertions, 3 deletions
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);
}