1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
//! 静态工具函数 - 其他 //! //! 对应 C# Static/Other.cs //! 包含日志初始化、管理员权限检测等功能。 /// 检测管理员权限(仅 Windows) /// /// 对应 C# AdminHelper.IsRunningAsAdmin() #[cfg(target_os = "windows")] pub fn is_running_as_admin() -> bool { // Rust 层面无法直接检测,委托给 DLL 或使用系统 API // 此处提供存根实现 false } #[cfg(not(target_os = "windows"))] pub fn is_running_as_admin() -> bool { // Linux: 检查 euid == 0 unsafe { libc::geteuid() == 0 } } /// 获取真实的系统版本字符串 pub fn get_system_version() -> String { #[cfg(target_os = "windows")] { // Windows: 返回 OS 版本 format!("Windows {}", std::env::consts::ARCH) } #[cfg(not(target_os = "windows"))] { format!("Linux {}", std::env::consts::ARCH) } }