@@ -62,14 +62,8 @@ public static void NormalInstall(bool isHant, bool isSilentMode = true)
6262 Utils . Reg . SetValue ( Registry . LocalMachine , WEASEL_PROG_REG_KEY , "ServerExecutable" , WEASEL_SERVER_EXE ) ;
6363
6464 // 启用键盘布局和文本服务
65- if ( isHant )
66- {
67- PInvoke . Input . InstallLayoutOrTip ( PSZTITLE_HANT , 0 ) ;
68- }
69- else
70- {
71- PInvoke . Input . InstallLayoutOrTip ( PSZTITLE_HANS , 0 ) ;
72- }
65+ var psz = isHant ? PSZTITLE_HANT : PSZTITLE_HANS ;
66+ PInvoke . Input . InstallLayoutOrTip ( psz , 0 ) ;
7367
7468 // 收集用户模式转储
7569 // https://learn.microsoft.com/zh-cn/windows/win32/wer/collecting-user-mode-dumps
@@ -94,14 +88,8 @@ public static void Uninstall(bool isSilentMode)
9488 var isHant = Convert . ToBoolean (
9589 Utils . Reg . GetValue ( Registry . CurrentUser , WEASEL_PROG_REG_KEY , "Hant" , 0 )
9690 ) ;
97- if ( isHant )
98- {
99- PInvoke . Input . InstallLayoutOrTip ( PSZTITLE_HANT , PInvoke . Input . ILOT . ILOT_UNINSTALL ) ;
100- }
101- else
102- {
103- PInvoke . Input . InstallLayoutOrTip ( PSZTITLE_HANS , PInvoke . Input . ILOT . ILOT_UNINSTALL ) ;
104- }
91+ var psz = isHant ? PSZTITLE_HANT : PSZTITLE_HANS ;
92+ PInvoke . Input . InstallLayoutOrTip ( psz , PInvoke . Input . ILOT . ILOT_UNINSTALL ) ;
10593
10694 UninstallImeFiles ( "weasel.dll" , ( imePath ) =>
10795 {
@@ -186,7 +174,8 @@ private static void InstallImeFiles(string srcPath, Action<string> updateService
186174 }
187175 else
188176 {
189- if ( File . Exists ( srcPath ) ) {
177+ if ( File . Exists ( srcPath ) )
178+ {
190179 File . Copy ( srcPath , destPath , true ) ;
191180 updateService ( destPath ) ;
192181 }
@@ -247,16 +236,10 @@ private static void UpdateServiceState(string libPath, bool enable, bool isHant)
247236 if ( ! enable ) UpdateProfile ( false , isHant ) ;
248237 var value = isHant ? "hant" : "hans" ;
249238 Environment . SetEnvironmentVariable ( "TEXTSERVICE_PROFILE" , value ) ;
250- string regsvr32Path ;
251239 var sysarm32Dir = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . Windows ) , "SysArm32" ) ;
252- if ( Directory . Exists ( sysarm32Dir ) )
253- {
254- regsvr32Path = Path . Combine ( sysarm32Dir , "regsvr32.exe" ) ;
255- }
256- else
257- {
258- regsvr32Path = "regsvr32.exe" ;
259- }
240+ var regsvr32Path = Directory . Exists ( sysarm32Dir )
241+ ? Path . Combine ( sysarm32Dir , "regsvr32.exe" )
242+ : "regsvr32.exe" ;
260243 var args = enable ? $ "/s \" { libPath } \" " : $ "/s /u \" { libPath } \" ";
261244 var updateInfo = new ProcessStartInfo
262245 {
0 commit comments