[dependencies]
winapi = { version = "0.3", features = ["sysinfoapi"] }
extern crate winapi;
use winapi::um::sysinfoapi::GetTickCount64;
fn get_windows_uptime() -> u64 {
unsafe { GetTickCount64() }
}
fn main() {
// 获取系统运行时间(以毫秒为单位)
let uptime_ms = get_windows_uptime();
// 将运行时间转换为秒
let uptime_secs = uptime_ms / 1000;
// 将运行时间转换为小时、分钟和秒
let days = uptime_secs / 86400;
let hours = (uptime_secs % 86400) / 3600;
let minutes = (uptime_secs % 3600) / 60;
let seconds = uptime_secs % 60;
println!("System uptime: {} days, {} hours, {} minutes, {} seconds", days, hours, minutes, seconds);
}
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
txttool.com 说一段 esp56物联 查询128 IP查询