Skip to content

Instantly share code, notes, and snippets.

@oakwhiz
Last active August 29, 2015 14:17
Show Gist options
  • Save oakwhiz/ec1ef551f889c4db2708 to your computer and use it in GitHub Desktop.
Save oakwhiz/ec1ef551f889c4db2708 to your computer and use it in GitHub Desktop.
A failed attempt to hide the console in Windows.
#![feature(thread_sleep, std_misc)]
extern crate winapi;
extern crate "kernel32-sys" as kernel32;
extern crate "user32-sys" as user32;
fn main() {
println!("About to hide the console.");
sleep(1);
unsafe {
user32::ShowWindow(kernel32::GetConsoleWindow(), winapi::SW_HIDE);
}
sleep(1);
println!("The console has been hidden. About to restore the console.");
sleep(1);
unsafe {
user32::ShowWindow(kernel32::GetConsoleWindow(), winapi::SW_RESTORE);
}
sleep(1);
println!("The console has been restored.");
sleep(1);
}
fn sleep(seconds: i64) {
std::thread::sleep(std::time::duration::Duration::seconds(seconds));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment