Skip to content

Commit

Permalink
feat: WeaselSetup.exe parameter /userdir:<user_data_dir_full_path> to…
Browse files Browse the repository at this point in the history
… set user data directory in command line
  • Loading branch information
fxliang committed Oct 18, 2024
1 parent 5d5d5b0 commit 0ef3154
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions WeaselSetup/WeaselSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ static int CustomInstall(bool installing) {
return 0;
}

LPCTSTR GetParamByPrefix(LPCTSTR lpCmdLine, LPCTSTR prefix) {
return (wcsncmp(lpCmdLine, prefix, wcslen(prefix)) == 0)
? (lpCmdLine + wcslen(prefix))
: 0;
}

static int Run(LPTSTR lpCmdLine) {
constexpr bool silent = true;
constexpr bool old_ime_support = false;
Expand All @@ -147,6 +153,11 @@ static int Run(LPTSTR lpCmdLine) {
return RestartAsAdmin(lpCmdLine);
}

if (auto res = GetParamByPrefix(lpCmdLine, L"/userdir:")) {
return SetRegKeyValue(HKEY_CURRENT_USER, L"Software\\Rime\\weasel",
L"RimeUserDir", res, REG_SZ);
}

if (!wcscmp(L"/ls", lpCmdLine)) {
return SetRegKeyValue(HKEY_CURRENT_USER, L"Software\\Rime\\weasel",
L"Language", L"chs", REG_SZ);
Expand Down

0 comments on commit 0ef3154

Please sign in to comment.