println in winmain
This commit is contained in:
		
							parent
							
								
									685d960b1e
								
							
						
					
					
						commit
						afd77181ff
					
				| @ -6,6 +6,18 @@ use hbb_common::log; | ||||
| #[cfg(not(any(target_os = "android", target_os = "ios")))] | ||||
| use hbb_common::platform::register_breakdown_handler; | ||||
| 
 | ||||
| #[macro_export] | ||||
| macro_rules! my_println{ | ||||
|     ($($arg:tt)*) => { | ||||
|         #[cfg(not(windows))] | ||||
|         println!("{}", format_args!($($arg)*)); | ||||
|         #[cfg(windows)] | ||||
|         crate::platform::message_box( | ||||
|             &format!("{}", format_args!($($arg)*)) | ||||
|         ); | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| /// shared by flutter and sciter main function
 | ||||
| ///
 | ||||
| /// [Note]
 | ||||
| @ -83,7 +95,7 @@ pub fn core_main() -> Option<Vec<String>> { | ||||
|         args.clear(); | ||||
|     } | ||||
|     if args.len() > 0 && args[0] == "--version" { | ||||
|         println!("{}", crate::VERSION); | ||||
|         my_println!("{}", crate::VERSION); | ||||
|         return None; | ||||
|     } | ||||
|     #[cfg(windows)] | ||||
| @ -225,16 +237,18 @@ pub fn core_main() -> Option<Vec<String>> { | ||||
|             if args.len() == 2 { | ||||
|                 if crate::platform::is_root() { | ||||
|                     crate::ipc::set_permanent_password(args[1].to_owned()).unwrap(); | ||||
|                     my_println!("Done!"); | ||||
|                 } else { | ||||
|                     println!("Administrative privileges required!"); | ||||
|                     my_println!("Administrative privileges required!"); | ||||
|                 } | ||||
|             } | ||||
|             return None; | ||||
|         } else if args[0] == "--get-id" { | ||||
|             #[cfg(windows)] | ||||
|             if crate::platform::is_root() { | ||||
|                 println!("{}", crate::ipc::get_id()); | ||||
|                 my_println!("{}", crate::ipc::get_id()); | ||||
|             } else { | ||||
|                 println!("Permission denied!"); | ||||
|                 my_println!("Permission denied!"); | ||||
|             } | ||||
|             return None; | ||||
|         } else if args[0] == "--check-hwcodec-config" { | ||||
|  | ||||
| @ -2297,3 +2297,26 @@ mod tests { | ||||
|         assert_eq!(chr, None) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| pub fn message_box(text: &str) { | ||||
|     let mut text = text.to_owned(); | ||||
|     if !text.ends_with("!") { | ||||
|         use arboard::Clipboard as ClipboardContext; | ||||
|         match ClipboardContext::new() { | ||||
|             Ok(mut ctx) => { | ||||
|                 ctx.set_text(&text).ok(); | ||||
|                 text = format!("{}\n\nAbove text has been copied to clipboard", &text); | ||||
|             } | ||||
|             _ => {} | ||||
|         } | ||||
|     } | ||||
|     let text = text | ||||
|         .encode_utf16() | ||||
|         .chain(std::iter::once(0)) | ||||
|         .collect::<Vec<u16>>(); | ||||
|     let caption = "RustDesk Output" | ||||
|         .encode_utf16() | ||||
|         .chain(std::iter::once(0)) | ||||
|         .collect::<Vec<u16>>(); | ||||
|     unsafe { MessageBoxW(std::ptr::null_mut(), text.as_ptr(), caption.as_ptr(), MB_OK) }; | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user