[fix] powerplan calling with black screen

This commit is contained in:
Purp1e
2025-03-22 21:44:27 +08:00
parent 446b26f186
commit ad5a1bd870
2 changed files with 9 additions and 3 deletions

View File

@@ -1,5 +1,9 @@
use std::collections::HashMap;
use std::process::Command;
use std::os::windows::process::CommandExt;
const CREATE_NO_WINDOW: u32 = 0x08000000;
// const DETACHED_PROCESS: u32 = 0x00000008;
pub struct PowerPlan {
power_plan_map: HashMap<i32, String>,
@@ -37,6 +41,7 @@ impl PowerPlan {
let output = Command::new("powercfg")
.arg("/S")
.arg(guid)
.creation_flags(CREATE_NO_WINDOW)
.output()
.map_err(|e| format!("Failed to execute powercfg command: {}", e))?;
@@ -53,6 +58,7 @@ impl PowerPlan {
pub fn get(&self) -> Result<i32, String> {
let output = Command::new("powercfg")
.arg("/L")
.creation_flags(CREATE_NO_WINDOW)
.output()
.map_err(|e| format!("Failed to execute powercfg command: {}", e))?;