mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-04-21 07:41:56 +00:00
Better way to hide the terminal
This commit is contained in:
parent
eea640a58f
commit
bfd9369f3c
2 changed files with 5 additions and 10 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -1,9 +1,8 @@
|
||||||
|
#![windows_subsystem = "windows"]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
use native_windows_gui::{self as nwg, NativeUi};
|
use native_windows_gui::{self as nwg, NativeUi};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
use winapi::um::wincon::GetConsoleWindow;
|
|
||||||
use winapi::um::winuser::{ShowWindow, SW_HIDE};
|
|
||||||
|
|
||||||
mod stremio_app;
|
mod stremio_app;
|
||||||
use crate::stremio_app::{stremio_server::StremioServer, MainWindow};
|
use crate::stremio_app::{stremio_server::StremioServer, MainWindow};
|
||||||
|
|
@ -24,14 +23,6 @@ struct Opt {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
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
|
// 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
|
// feature. It supports the "System DPI Awareness" mode, but not the more
|
||||||
// advanced Per-Monitor (v2) DPI Awareness modes.
|
// advanced Per-Monitor (v2) DPI Awareness modes.
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@ use std::process::Command;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use win32job::Job;
|
use win32job::Job;
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
|
|
||||||
|
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||||
|
|
||||||
pub struct StremioServer {}
|
pub struct StremioServer {}
|
||||||
|
|
||||||
|
|
@ -16,6 +19,7 @@ impl StremioServer {
|
||||||
loop {
|
loop {
|
||||||
let mut child = Command::new("node")
|
let mut child = Command::new("node")
|
||||||
.arg("server.js")
|
.arg("server.js")
|
||||||
|
.creation_flags(CREATE_NO_WINDOW)
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("Cannot run the server");
|
.expect("Cannot run the server");
|
||||||
child.wait().expect("Cannot wait for the server");
|
child.wait().expect("Cannot wait for the server");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue