[feat] better installer + changelog test version switch + better video config view
This commit is contained in:
@@ -81,6 +81,40 @@ pub fn open_path(path: &str) -> Result<(), std::io::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn check_process_running(name: &str) -> bool {
|
||||
// 使用tasklist命令检查进程是否存在
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let output = Command::new("tasklist")
|
||||
.args(&["/FI", &format!("IMAGENAME eq {}", name)])
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
.output();
|
||||
|
||||
if let Ok(output) = output {
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
// 检查输出中是否包含进程名(排除表头)
|
||||
stdout.contains(name) && stdout.contains("exe")
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
// 对于非Windows系统,可以使用ps命令
|
||||
let output = Command::new("pgrep")
|
||||
.arg("-f")
|
||||
.arg(name)
|
||||
.output();
|
||||
|
||||
if let Ok(output) = output {
|
||||
!output.stdout.is_empty()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod tests {
|
||||
#[test]
|
||||
fn test_open_path() {
|
||||
|
||||
Reference in New Issue
Block a user