From 7913305260a62d479d3d58d526ff13fe1e0d2d5c Mon Sep 17 00:00:00 2001 From: TheWhiteDog9487 Date: Tue, 11 Aug 2026 16:27:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=BB=E5=BA=95=E7=A7=BB=E9=99=A4P/Invoke?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E8=A7=A3=E5=86=B3=E8=BF=90=E8=A1=8C=E6=97=B6?= =?UTF-8?q?DLL=E6=89=BE=E4=B8=8D=E5=88=B0=E7=9A=84=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?=E8=99=BD=E7=84=B6=E4=B8=8D=E9=9C=80=E8=A6=81=E8=B0=83=E7=94=A8?= =?UTF-8?q?libc=E4=BA=86=EF=BC=8C=E4=BD=86=E6=98=AF=E4=BB=8D=E7=84=B6?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E9=9D=99=E6=80=81=E9=93=BE=E6=8E=A5=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E7=84=B6=E8=BF=98=E6=98=AF=E4=BC=9A=E5=87=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- language.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/language.cs b/language.cs index ac1baa3..bb2b049 100644 --- a/language.cs +++ b/language.cs @@ -6,15 +6,13 @@ #:property OptimizationPreference=Speed // #:property OptimizationPreference=Size #:property InvariantGlobalization=true +// ↑ 这个东西需要libicu // #:property StackTraceSupport=false using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; -[DllImport("libc", EntryPoint = "geteuid")] -static extern uint GetEffectiveUserId(); - void CheckUser(string DisplayMessage = "即将开始更新语言配置"){ Console.WriteLine(DisplayMessage); Console.WriteLine("按回车继续,按Esc取消"); @@ -81,7 +79,7 @@ if (Enum.TryParse(OsDescription.Split(' ')[0], out 如果是误报,请在GitHub仓库打开一个新的issue。 ".Trim(); throw new NotSupportedException(Message); } } -if (GetEffectiveUserId() != 0){ +if (Environment.IsPrivilegedProcess == false){ throw new UnauthorizedAccessException("更改语言文件需要root权限,请使用sudo重新运行本程序"); } Console.WriteLine($"探测到当前系统为 {OsDescription}");