feat: finish highlevel register
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
use crate::{lowlevel, utilities, win32::{self, concept}};
|
use crate::{
|
||||||
|
lowlevel, utilities,
|
||||||
|
win32::{self, concept},
|
||||||
|
};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
@@ -462,9 +465,12 @@ impl Program {
|
|||||||
debug_println!("Adding ProgId subkey...");
|
debug_println!("Adding ProgId subkey...");
|
||||||
for program_progid_key in &mut self.ext_keys {
|
for program_progid_key in &mut self.ext_keys {
|
||||||
let progid_key = &mut program_progid_key.progid_key;
|
let progid_key = &mut program_progid_key.progid_key;
|
||||||
|
debug_println!(
|
||||||
|
"Adding ProgId \"{0}\" subkey...",
|
||||||
|
progid_key.inner().to_string()
|
||||||
|
);
|
||||||
|
|
||||||
// Create ProgId subkey
|
// Create ProgId subkey
|
||||||
debug_println!("Adding ProgId \"{0}\" subkey...", progid_key.inner().to_string());
|
|
||||||
progid_key.ensure(scope)?;
|
progid_key.ensure(scope)?;
|
||||||
// Write ProgId values
|
// Write ProgId values
|
||||||
let name = Some(&program_progid_key.name.inner);
|
let name = Some(&program_progid_key.name.inner);
|
||||||
@@ -472,6 +478,10 @@ impl Program {
|
|||||||
progid_key.set_shell_verb(scope, &program_progid_key.behavior.inner)?;
|
progid_key.set_shell_verb(scope, &program_progid_key.behavior.inner)?;
|
||||||
progid_key.set_friendly_type_name(scope, name)?;
|
progid_key.set_friendly_type_name(scope, name)?;
|
||||||
progid_key.set_default_icon(scope, Some(&program_progid_key.icon.inner))?;
|
progid_key.set_default_icon(scope, Some(&program_progid_key.icon.inner))?;
|
||||||
|
|
||||||
|
// Add this progid to file extension "open with" list.
|
||||||
|
let ext_key = &mut program_progid_key.ext_key;
|
||||||
|
ext_key.add_into_open_with_progids(scope, progid_key.inner())?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything is okey.
|
// Everything is okey.
|
||||||
@@ -493,16 +503,25 @@ impl Program {
|
|||||||
debug_println!("Deleting Applications subkey...");
|
debug_println!("Deleting Applications subkey...");
|
||||||
self.applications_key.delete(scope)?;
|
self.applications_key.delete(scope)?;
|
||||||
|
|
||||||
// According to Microsoft document, when uninstalling application,
|
// Delete ProgId subkeys one by one.
|
||||||
// it is enough that only delete ProgId keys.
|
|
||||||
// Programmer doesn't need to edit something in Ext keys.
|
|
||||||
// So we delete ProgId subkeys one by one in there.
|
|
||||||
debug_println!("Adding ProgId subkey...");
|
debug_println!("Adding ProgId subkey...");
|
||||||
for program_progid_key in &mut self.ext_keys {
|
for program_progid_key in &mut self.ext_keys {
|
||||||
let progid_key = &mut program_progid_key.progid_key;
|
let progid_key = &mut program_progid_key.progid_key;
|
||||||
|
debug_println!(
|
||||||
|
"Deleting ProgId \"{0}\" subkey...",
|
||||||
|
progid_key.inner().to_string()
|
||||||
|
);
|
||||||
|
|
||||||
|
// YYC MARK:
|
||||||
|
// According to Microsoft document, when uninstalling application,
|
||||||
|
// there is no need to reset the default open way of file extension.
|
||||||
|
// So we simply remove it from "open with" list.
|
||||||
|
|
||||||
|
// Remove this ProgId from file extension "open with" list.
|
||||||
|
let ext_key = &mut program_progid_key.ext_key;
|
||||||
|
ext_key.remove_from_open_with_progids(scope, progid_key.inner())?;
|
||||||
|
|
||||||
// Delete ProgId subkey
|
// Delete ProgId subkey
|
||||||
debug_println!("Deleting ProgId \"{0}\" subkey...", progid_key.inner().to_string());
|
|
||||||
progid_key.delete(scope)?;
|
progid_key.delete(scope)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,8 +536,35 @@ impl Program {
|
|||||||
/// Please note that this is a rough check and do not validate any data.
|
/// Please note that this is a rough check and do not validate any data.
|
||||||
///
|
///
|
||||||
/// The return value only ensures the pre-requirement of `register` and `unregister`.
|
/// The return value only ensures the pre-requirement of `register` and `unregister`.
|
||||||
pub fn is_registered(&self, view: View) -> Result<bool, ProgramError> {
|
pub fn is_registered(&self, scope: Scope) -> Result<bool, ProgramError> {
|
||||||
todo!()
|
// Check App Paths subkey.
|
||||||
|
debug_println!("Checking App Paths subkey...");
|
||||||
|
if !self.app_paths_key.is_exist(scope)? {
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check Application subkey.
|
||||||
|
debug_println!("Checking Applications subkey...");
|
||||||
|
if !self.applications_key.is_exist(scope.into())? {
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check ProgId subkey.
|
||||||
|
debug_println!("Checking ProgId subkey...");
|
||||||
|
for program_progid_key in &self.ext_keys {
|
||||||
|
let progid_key = &program_progid_key.progid_key;
|
||||||
|
debug_println!(
|
||||||
|
"Checking ProgId \"{0}\" subkey...",
|
||||||
|
progid_key.inner().to_string()
|
||||||
|
);
|
||||||
|
|
||||||
|
if !progid_key.is_exist(scope.into())? {
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Every subkeys are roughly existing.
|
||||||
|
Ok(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn link_ext(&self, scope: Scope, index: usize) -> Result<(), ProgramError> {
|
pub fn link_ext(&self, scope: Scope, index: usize) -> Result<(), ProgramError> {
|
||||||
|
|||||||
Reference in New Issue
Block a user