From c8c726b5651b5f7ce3b2162e011570a326048aa0 Mon Sep 17 00:00:00 2001 From: Kingtous Date: Mon, 31 Oct 2022 14:59:57 +0800 Subject: [PATCH] feat: support hot,key specification in portable file name --- src/common.rs | 3 +++ src/platform/windows.rs | 8 +++++++- src/ui_interface.rs | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/common.rs b/src/common.rs index 8a9890319..78e3147ec 100644 --- a/src/common.rs +++ b/src/common.rs @@ -26,6 +26,9 @@ pub type NotifyMessageBox = fn(String, String, String, String) -> dyn Future> = Default::default(); pub static ref SOFTWARE_UPDATE_URL: Arc> = Default::default(); diff --git a/src/platform/windows.rs b/src/platform/windows.rs index ed9ac7e9b..ae9574f33 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -1,4 +1,5 @@ use super::{CursorData, ResultType}; +use crate::common::PORTABLE_APPNAME_RUNTIME_ENV_KEY; use crate::ipc; use crate::license::*; use hbb_common::{ @@ -1333,7 +1334,12 @@ fn get_reg_of(subkey: &str, name: &str) -> String { } fn get_license_from_exe_name() -> ResultType { - let exe = std::env::current_exe()?.to_str().unwrap_or("").to_owned(); + let mut exe = std::env::current_exe()?.to_str().unwrap_or("").to_owned(); + // if defined portable appname entry, replace original executable name with it. + if let Ok(portable_exe) = std::env::var(PORTABLE_APPNAME_RUNTIME_ENV_KEY) { + exe = portable_exe; + log::debug!("update portable executable name to {}", exe); + } get_license_from_string(&exe) } diff --git a/src/ui_interface.rs b/src/ui_interface.rs index 0f7db9a1d..cb2c178d6 100644 --- a/src/ui_interface.rs +++ b/src/ui_interface.rs @@ -141,6 +141,11 @@ pub fn has_rendezvous_service() -> bool { pub fn get_license() -> String { #[cfg(windows)] if let Some(lic) = crate::platform::windows::get_license() { + #[cfg(feature = "flutter")] + { + return format!("Key: {}\nHost: {}\nApi: {}", lic.key, lic.host, lic.api); + } + // default license format is html formed (sciter) return format!( "
Key: {}
Host: {} Api: {}", lic.key, lic.host, lic.api