Skip to content

Commit

Permalink
load settings from INI file if exists in the same directory of the ex…
Browse files Browse the repository at this point in the history
…ecutable regardless of the drive type
  • Loading branch information
zodiacon committed Nov 11, 2022
1 parent 42f54fa commit 52320cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions RegExp/LocationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Binary file modified RegExp/RegExp.rc
Binary file not shown.

0 comments on commit 52320cd

Please sign in to comment.