alloc_console does work, but it create another cmd window, seems not

better than dialog
This commit is contained in:
rustdesk 2023-07-17 18:52:43 +08:00
parent 4ed9aa39c7
commit 76a6b4e09e
2 changed files with 11 additions and 0 deletions

View File

@ -628,4 +628,8 @@ extern "C"
return bSystem;
}
void alloc_console_and_redirect() {
AllocConsole();
freopen("CONOUT$", "w", stdout);
}
} // end of extern "C"

View File

@ -455,6 +455,7 @@ extern "C" {
fn win_stop_system_key_propagate(v: BOOL);
fn is_win_down() -> BOOL;
fn is_local_system() -> BOOL;
fn alloc_console_and_redirect();
}
extern "system" {
@ -2383,3 +2384,9 @@ pub fn message_box(text: &str) {
.collect::<Vec<u16>>();
unsafe { MessageBoxW(std::ptr::null_mut(), text.as_ptr(), caption.as_ptr(), MB_OK) };
}
pub fn alloc_console() {
unsafe {
alloc_console_and_redirect();
}
}