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 3c70aed commit f5bccb3
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 @@ -134,13 +134,24 @@ 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;
bool uninstalling = !wcscmp(L"/u", lpCmdLine);
if (uninstalling)
return uninstall(silent);

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 f5bccb3

Please sign in to comment.