MCPcopy Create free account
hub / github.com/PowerShell/DSC / query

Method query

archive/ntreg/src/registry_value.rs:49–71  ·  view source on GitHub ↗

Refresh the contents of a registry value. # Example ``` # use ntreg::registry_key::RegistryKey; let key = RegistryKey::new(r"HKCU\Environment").unwrap(); let mut value = key.get_value("Path").unwrap(); assert!(value.query().is_ok());

(&mut self)

Source from the content-addressed store, hash-verified

47 /// let mut value = key.get_value("Path").unwrap();
48 /// assert!(value.query().is_ok());
49 pub fn query(&mut self) -> Result<(), NtStatusError> {
50 let key = RegistryKey::new(self.key_path.clone().as_str())?;
51 let value_name_unicode = self.name.as_unicode_string();
52 let mut len = size_of::<KEY_VALUE_FULL_INFORMATION>() as u32 + key.max_value_name_len + key.max_data_len + 2; // +2 for the null terminators
53 let buf: Vec<u8> = vec![0; len as usize];
54 let value_information: PKEY_VALUE_FULL_INFORMATION = buf.as_ptr() as PKEY_VALUE_FULL_INFORMATION;
55 let status = unsafe {
56 ntregapi::NtQueryValueKey(
57 key.handle,
58 &mut value_name_unicode.as_struct() as *mut UNICODE_STRING,
59 ntregapi::KeyValueFullInformation,
60 value_information as *mut c_void,
61 len,
62 &mut len)
63 };
64
65 if !NT_SUCCESS(status) {
66 return Err(NtStatusError::new(status, "Failed to query registry value"));
67 }
68
69 self.data = get_data_value(value_information);
70 Ok(())
71 }
72}
73
74/// Represents a registry key's values iterator.

Callers 2

get_valueMethod · 0.80
set_valueMethod · 0.80

Calls 5

get_data_valueFunction · 0.85
as_strMethod · 0.80
as_unicode_stringMethod · 0.80
as_structMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected