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 8a628fe commit 5171cc8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions WeaselSetup/WeaselSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "resource.h"
#include "WeaselUtility.h"
#include <thread>
#include <iostream>

#include "InstallOptionsDlg.h"

Expand Down Expand Up @@ -134,13 +135,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 5171cc8

Please sign in to comment.