mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-06 08:32:51 +08:00
🐛 修复mac编译异常
This commit is contained in:
@@ -77,10 +77,12 @@ pub fn is_in_admin() -> bool {
|
||||
{
|
||||
return Err("This function is only supported on Windows.".into());
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
use windows_sys::Win32::Foundation::{CloseHandle, HANDLE};
|
||||
use windows_sys::Win32::Security::{
|
||||
AllocateAndInitializeSid, CheckTokenMembership, FreeSid, SID_IDENTIFIER_AUTHORITY, TOKEN_QUERY,
|
||||
AllocateAndInitializeSid, CheckTokenMembership, FreeSid, SID_IDENTIFIER_AUTHORITY,
|
||||
TOKEN_QUERY,
|
||||
};
|
||||
use windows_sys::Win32::System::SystemServices::{
|
||||
DOMAIN_ALIAS_RID_ADMINS, SECURITY_BUILTIN_DOMAIN_RID,
|
||||
@@ -123,6 +125,7 @@ pub fn is_in_admin() -> bool {
|
||||
|
||||
result != 0 && is_admin != 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 以管理员权限重启应用
|
||||
@@ -132,7 +135,8 @@ pub fn run_with_admin() -> Result<(), String> {
|
||||
{
|
||||
return Err("This function is only supported on Windows.".into());
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
use std::ffi::OsStr;
|
||||
use std::iter::once;
|
||||
use std::os::windows::ffi::OsStrExt;
|
||||
@@ -176,4 +180,5 @@ pub fn run_with_admin() -> Result<(), String> {
|
||||
Err("Failed to restart as administrator via cmd.".into())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user