diff --git a/WeaselSetup/WeaselSetup.cpp b/WeaselSetup/WeaselSetup.cpp index 259af11f7..10ead4e03 100644 --- a/WeaselSetup/WeaselSetup.cpp +++ b/WeaselSetup/WeaselSetup.cpp @@ -6,6 +6,7 @@ #include "resource.h" #include "WeaselUtility.h" #include +#include #include "InstallOptionsDlg.h" @@ -134,6 +135,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; @@ -141,6 +148,11 @@ static int Run(LPTSTR 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);