use rgpui::Result;
const RUN_KEY_PATH: &str = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
pub fn set_auto_launch(app_id: &str, enabled: bool) -> Result<()> {
let key = windows_registry::CURRENT_USER.create(RUN_KEY_PATH)?;
if enabled {
let exe_path = std::env::current_exe()?;
key.set_string(app_id, &exe_path.to_string_lossy())?;
} else {
key.remove_value(app_id)?;
}
Ok(())
}
pub fn is_auto_launch_enabled(app_id: &str) -> bool {
if let Ok(key) = windows_registry::CURRENT_USER.open(RUN_KEY_PATH) {
key.get_string(app_id).is_ok()
} else {
false
}
}