Send an IPC command to the running THide instance
(message: u32, success_msg: &str)
| 45 | |
| 46 | /// Send an IPC command to the running THide instance |
| 47 | fn send_command(message: u32, success_msg: &str) -> Result<(), Box<dyn std::error::Error>> { |
| 48 | unsafe { |
| 49 | let class_name: Vec<u16> = format!("{}\0", IPC_WINDOW_CLASS).encode_utf16().collect(); |
| 50 | |
| 51 | match FindWindowW( |
| 52 | windows::core::PCWSTR(class_name.as_ptr()), |
| 53 | windows::core::PCWSTR::null(), |
| 54 | ) { |
| 55 | Ok(hwnd) if !hwnd.0.is_null() => { |
| 56 | let _ = PostMessageW(hwnd, message, WPARAM(0), LPARAM(0)); |
| 57 | println!("{}", success_msg); |
| 58 | Ok(()) |
| 59 | } |
| 60 | _ => { |
| 61 | eprintln!("Error: THide is not running!"); |
| 62 | std::process::exit(1); |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | /// Check if THide is currently running |
| 69 | fn is_thide_running() -> bool { |
no outgoing calls
no test coverage detected