Query the service description string.
(service_handle: SC_HANDLE)
| 313 | |
| 314 | /// Query the service description string. |
| 315 | unsafe fn query_description(service_handle: SC_HANDLE) -> Option<String> { |
| 316 | let mut bytes_needed: u32 = 0; |
| 317 | let _ = unsafe { |
| 318 | QueryServiceConfig2W( |
| 319 | service_handle, |
| 320 | SERVICE_CONFIG_DESCRIPTION, |
| 321 | None, |
| 322 | &mut bytes_needed, |
| 323 | ) |
| 324 | }; |
| 325 | |
| 326 | if bytes_needed == 0 { |
| 327 | return None; |
| 328 | } |
| 329 | |
| 330 | let mut buffer = vec![0u8; bytes_needed as usize]; |
| 331 | if unsafe { |
| 332 | QueryServiceConfig2W( |
| 333 | service_handle, |
| 334 | SERVICE_CONFIG_DESCRIPTION, |
| 335 | Some(&mut buffer), |
| 336 | &mut bytes_needed, |
| 337 | ) |
| 338 | } |
| 339 | .is_ok() |
| 340 | { |
| 341 | let desc = unsafe { &*(buffer.as_ptr().cast::<SERVICE_DESCRIPTIONW>()) }; |
| 342 | if desc.lpDescription.is_null() { |
| 343 | None |
| 344 | } else { |
| 345 | unsafe { desc.lpDescription.to_string().ok() } |
| 346 | } |
| 347 | } else { |
| 348 | None |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | /// Query the current runtime status of a service. |
| 353 | unsafe fn query_status(service_handle: SC_HANDLE) -> Result<ServiceStatus, ServiceError> { |
no outgoing calls
no test coverage detected