从 Windows 注册表 (winapi) 打开密钥

问题描述 投票:0回答:0

嗨,我尝试使用 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)
。我不知道我在这里做错了什么......

windows winapi rust window-crate
© www.soinside.com 2019 - 2024. All rights reserved.