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

Method remove_capability

resources/dism_dsc/src/dism.rs:484–505  ·  view source on GitHub ↗

Returns `Ok(true)` if DISM reports a reboot is required (HRESULT 3010).

(&self, name: &str)

Source from the content-addressed store, hash-verified

482
483 /// Returns `Ok(true)` if DISM reports a reboot is required (HRESULT 3010).
484 pub fn remove_capability(&self, name: &str) -> Result<bool, String> {
485 let remove_cap = self.api.remove_capability
486 .ok_or_else(|| t!("dism.capabilitiesNotSupported").to_string())?;
487
488 let wide_name = to_wide_null(name);
489 let hr = unsafe {
490 remove_cap(
491 self.handle,
492 wide_name.as_ptr(),
493 std::ptr::null_mut(), // CancelEvent
494 std::ptr::null_mut(), // Progress
495 std::ptr::null_mut(), // UserData
496 )
497 };
498 if hr == DISMAPI_E_CAPABILITY_NOT_APPLICABLE {
499 return Ok(false); // Already not present — nothing to do
500 }
501 if hr < 0 {
502 return Err(t!("dism.removeCapabilityFailed", name = name, hr = format!("0x{:08X}", hr as u32)).to_string());
503 }
504 Ok(hr == ERROR_SUCCESS_REBOOT_REQUIRED)
505 }
506
507 pub fn get_all_capability_basics(&self) -> Result<Vec<(String, i32)>, String> {
508 let get_caps = self.api.get_capabilities

Callers 1

handle_setFunction · 0.80

Calls 1

to_wide_nullFunction · 0.85

Tested by

no test coverage detected