mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 15:44:35 +01:00
wipe registry option
This commit is contained in:
@@ -2,6 +2,9 @@ use duct::cmd;
|
||||
use ini::Ini;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[cfg(windows)]
|
||||
use registry::{Data, Hive, Security};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn run_program(path: String, args: Option<String>) {
|
||||
// Without unwrap_or, this can crash when UAC prompt is denied
|
||||
@@ -127,6 +130,28 @@ pub fn set_migoto_target(path: String, migoto_path: String) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn wipe_registry(exec_name: String) {
|
||||
// Fetch the 'Internet Settings' registry key.
|
||||
let settings =
|
||||
match Hive::CurrentUser.open(format!("Software\\miHoYo\\{}", exec_name), Security::Write) {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
println!("Error getting registry setting: {}", e);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// Wipe login cache
|
||||
match settings.set_value(
|
||||
"MIHOYOSDK_ADL_PROD_OVERSEA_h1158948810",
|
||||
&Data::String("".parse().unwrap()),
|
||||
) {
|
||||
Ok(_) => (),
|
||||
Err(e) => println!("Error wiping registry: {}", e),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[tauri::command]
|
||||
pub fn is_elevated() -> bool {
|
||||
|
||||
Reference in New Issue
Block a user