Better way to hide the terminal

This commit is contained in:
Vladimir Borisov 2021-11-17 11:24:25 +02:00
parent 3cedaf9afb
commit 76ff6cac5b
2 changed files with 5 additions and 10 deletions

View file

@ -1,9 +1,8 @@
#![windows_subsystem = "windows"]
#[macro_use]
extern crate bitflags;
use native_windows_gui::{self as nwg, NativeUi};
use structopt::StructOpt;
use winapi::um::wincon::GetConsoleWindow;
use winapi::um::winuser::{ShowWindow, SW_HIDE};
mod stremio_app;
use crate::stremio_app::{stremio_server::StremioServer, MainWindow};
@ -24,14 +23,6 @@ struct Opt {
}
fn main() {
// Hide the terminal window
let window = unsafe { GetConsoleWindow() };
if !window.is_null() {
unsafe {
ShowWindow(window, SW_HIDE);
}
}
// native-windows-gui has some basic high DPI support with the high-dpi
// feature. It supports the "System DPI Awareness" mode, but not the more
// advanced Per-Monitor (v2) DPI Awareness modes.

View file

@ -2,6 +2,9 @@ use std::process::Command;
use std::thread;
use std::time::Duration;
use win32job::Job;
use std::os::windows::process::CommandExt;
const CREATE_NO_WINDOW: u32 = 0x08000000;
pub struct StremioServer {}
@ -16,6 +19,7 @@ impl StremioServer {
loop {
let mut child = Command::new("node")
.arg("server.js")
.creation_flags(CREATE_NO_WINDOW)
.spawn()
.expect("Cannot run the server");
child.wait().expect("Cannot wait for the server");