嗨,我尝试使用 windows-crate 打开注册表项(https://crates.io/crates/windows)
unsafe {
let hkey: *mut HKEY = ptr::null_mut();
let reg_open_result = windows::Win32::System::Registry::RegOpenKeyExA(
HKEY_LOCAL_MACHINE,
s!("SOFTWARE"),
0 as u32,
KEY_QUERY_VALUE,
hkey
);
println!(">>> {:?}", reg_open_result);
println!(">>> {:?}", hkey);
}
宏
s!
定义如下:
#[macro_export]
macro_rules! s {
($s:literal) => {
$crate::core::PCSTR::from_raw(::std::concat!($s, '\0').as_ptr())
};
}
打电话给我
WIN32_ERROR(87)
。我不知道我在这里做错了什么......