Skip to content

Commit b0b7b83

Browse files
authored
Merge pull request #1865 from berryzplus/feature/fix_exeini_settings
マルチユーザー設定ファイルの不具合修正
2 parents 64fb6f7 + 128f442 commit b0b7b83

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

sakura_core/_main/CControlProcess.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,24 @@ std::filesystem::path CControlProcess::GetIniFileName() const
6464
*/
6565
std::filesystem::path CControlProcess::GetPrivateIniFileName(const std::wstring& exeIniPath, const std::wstring& filename) const
6666
{
67+
const auto nFolder = ::GetPrivateProfileInt(L"Settings", L"UserRootFolder", 0, exeIniPath.c_str());
6768
KNOWNFOLDERID refFolderId;
68-
switch (int nFolder = ::GetPrivateProfileInt(L"Settings", L"UserRootFolder", 0, exeIniPath.c_str())) {
69+
switch (nFolder) {
6970
case 1:
71+
case 3:
7072
refFolderId = FOLDERID_Profile; // ユーザーのルートフォルダー
7173
break;
7274
case 2:
7375
refFolderId = FOLDERID_Documents; // ユーザーのドキュメントフォルダー
7476
break;
75-
case 3:
76-
refFolderId = FOLDERID_Desktop; // ユーザーのデスクトップフォルダー
77-
break;
77+
7878
default:
7979
refFolderId = FOLDERID_RoamingAppData; // ユーザーのアプリケーションデータフォルダー
8080
break;
8181
}
8282

8383
PWSTR pFolderPath = nullptr;
84-
::SHGetKnownFolderPath(refFolderId, KF_FLAG_DEFAULT, nullptr, &pFolderPath);
84+
::SHGetKnownFolderPath(refFolderId, KF_FLAG_DEFAULT_PATH, NULL, &pFolderPath);
8585
std::filesystem::path privateIniPath(pFolderPath);
8686
::CoTaskMemFree(pFolderPath);
8787

@@ -92,6 +92,9 @@ std::filesystem::path CControlProcess::GetPrivateIniFileName(const std::wstring&
9292
{
9393
subFolder = L"sakura";
9494
}
95+
if (nFolder == 3) {
96+
privateIniPath.append("Desktop");
97+
}
9598
privateIniPath.append(subFolder);
9699

97100
if (const auto* pCommandLine = CCommandLine::getInstance(); pCommandLine->IsSetProfile() && *pCommandLine->GetProfileName()) {

0 commit comments

Comments
 (0)