opt elevation code

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-01-28 16:41:47 +08:00
parent 7c2d7df62e
commit 3e4a867115
4 changed files with 102 additions and 77 deletions

View File

@@ -956,15 +956,17 @@ fn start_uac_elevation_check() {
START.call_once(|| {
if !crate::platform::is_installed()
&& !crate::platform::is_root()
&& !crate::platform::is_elevated(None).map_or(false, |b| b)
&& !crate::portable_service::client::running()
{
std::thread::spawn(|| loop {
std::thread::sleep(std::time::Duration::from_secs(1));
if let Ok(uac) = crate::ui::win_privacy::is_process_consent_running() {
*IS_UAC_RUNNING.lock().unwrap() = uac;
}
if let Ok(elevated) = crate::platform::is_foreground_window_elevated() {
*IS_FOREGROUND_WINDOW_ELEVATED.lock().unwrap() = elevated;
if !crate::platform::is_elevated(None).unwrap_or(false) {
if let Ok(elevated) = crate::platform::is_foreground_window_elevated() {
*IS_FOREGROUND_WINDOW_ELEVATED.lock().unwrap() = elevated;
}
}
});
}