From 52320cde1d680a2021894500879dbd2598907090 Mon Sep 17 00:00:00 2001 From: Pavel Yosifovich Date: Fri, 11 Nov 2022 17:54:53 -0500 Subject: [PATCH] load settings from INI file if exists in the same directory of the executable regardless of the drive type --- RegExp/LocationManager.cpp | 14 +++++++++----- RegExp/RegExp.rc | Bin 66168 -> 66168 bytes WTLHelper | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/RegExp/LocationManager.cpp b/RegExp/LocationManager.cpp index 16ef1a5..ab72c2f 100644 --- a/RegExp/LocationManager.cpp +++ b/RegExp/LocationManager.cpp @@ -94,12 +94,16 @@ bool LocationManager::SaveToFile(PCWSTR path) const { bool LocationManager::Load(PCWSTR path) { WCHAR fullpath[MAX_PATH]; ::GetModuleFileName(nullptr, fullpath, _countof(fullpath)); - auto ch = fullpath[3]; - fullpath[3] = 0; - if (::GetDriveType(fullpath) == DRIVE_FIXED) - return LoadFromRegistry(path); - fullpath[3] = ch; wcscpy_s(fullpath + wcslen(fullpath) - 3, _countof(fullpath), L"ini"); + if (::GetFileAttributes(fullpath) == INVALID_FILE_ATTRIBUTES) { + // + // INIT file does not exist, load from Registry + // + return LoadFromRegistry(path); + } + // + // load from file + // return LoadFromFile(fullpath); } diff --git a/RegExp/RegExp.rc b/RegExp/RegExp.rc index af0dd97672536ea476cb61f35598cf86c137e07a..4929f3422ec3820b6c845a2aaf00407f196151d1 100644 GIT binary patch delta 52 zcmey-!t$eqWrNx~Mx)8