flutter windows main.cpp get app name from rust (#7316)

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2024-03-06 17:57:05 +08:00
committed by GitHub
parent f3686b23c7
commit dd44bb2a0c
3 changed files with 23 additions and 4 deletions

View File

@@ -154,6 +154,17 @@ pub unsafe extern "C" fn free_c_args(ptr: *mut *mut c_char, len: c_int) {
// Afterwards the vector will be dropped and thus freed.
}
#[cfg(windows)]
#[no_mangle]
pub unsafe extern "C" fn get_rustdesk_app_name(buffer: *mut u16, length: i32) -> i32 {
let name = crate::platform::wide_string(&crate::get_app_name());
if length > name.len() as i32 {
std::ptr::copy_nonoverlapping(name.as_ptr(), buffer, name.len());
return 0;
}
-1
}
#[derive(Default)]
struct SessionHandler {
event_stream: Option<StreamSink<EventToUI>>,

View File

@@ -1748,7 +1748,7 @@ pub fn get_double_click_time() -> u32 {
unsafe { GetDoubleClickTime() }
}
fn wide_string(s: &str) -> Vec<u16> {
pub fn wide_string(s: &str) -> Vec<u16> {
use std::os::windows::prelude::OsStrExt;
std::ffi::OsStr::new(s)
.encode_wide()