try cpu once more
This commit is contained in:
@@ -470,7 +470,7 @@ fn get_cpu_temp() -> Option<f32> {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
use com::runtime::init_runtime;
|
||||
use com::sys::{CLSCTX_INPROC_SERVER, COINIT_MULTITHREADED};
|
||||
use com::sys::{CLSCTX_INPROC_SERVER, COINIT_MULTITHREADED, FAILED};
|
||||
use widestring::U16CString;
|
||||
use winapi::shared::rpcdce::*;
|
||||
use winapi::shared::wtypes::VT_I4;
|
||||
@@ -560,12 +560,24 @@ fn get_cpu_temp() -> Option<f32> {
|
||||
let mut obj: *mut wbemcli::IWbemClassObject = std::ptr::null_mut();
|
||||
let mut returned = 0;
|
||||
let hr = (*enumerator).Next(
|
||||
wbemcli::WBEM_INFINITE.try_into().unwrap(),
|
||||
wbemcli::WBEM_INFINITE as i32, // Fixed: cast directly to i32
|
||||
1,
|
||||
&mut obj,
|
||||
&mut returned,
|
||||
);
|
||||
|
||||
if FAILED(hr) {
|
||||
eprintln!("Failed to enumerate WMI objects (HRESULT: {})", hr);
|
||||
(*enumerator).Release();
|
||||
continue;
|
||||
}
|
||||
|
||||
if returned == 0 {
|
||||
// No more items
|
||||
(*enumerator).Release();
|
||||
continue;
|
||||
}
|
||||
|
||||
if hr == 0 && returned > 0 {
|
||||
let mut variant = std::mem::zeroed::<VARIANT>();
|
||||
// Try different possible property names
|
||||
|
Reference in New Issue
Block a user