|
@ -8,18 +8,56 @@ |
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
// except according to those terms.
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
|
extern crate winapi; |
|
|
|
|
|
extern crate advapi32; |
|
|
|
|
|
|
|
|
|
|
|
use std::io; |
|
|
|
|
|
use std::ffi::{OsString, OsStr}; |
|
|
use std::ffi::{OsString, OsStr}; |
|
|
use std::os::windows::prelude::*; |
|
|
use std::io; |
|
|
use std::ops::RangeFrom; |
|
|
use std::ops::RangeFrom; |
|
|
use self::winapi::*; |
|
|
use std::os::raw; |
|
|
use self::advapi32::*; |
|
|
use std::os::windows::prelude::*; |
|
|
|
|
|
|
|
|
pub struct RegistryKey(Repr); |
|
|
pub struct RegistryKey(Repr); |
|
|
|
|
|
|
|
|
|
|
|
type HKEY = *mut u8; |
|
|
|
|
|
type DWORD = u32; |
|
|
|
|
|
type LPDWORD = *mut DWORD; |
|
|
|
|
|
type LPCWSTR = *const u16; |
|
|
|
|
|
type LPWSTR = *mut u16; |
|
|
|
|
|
type LONG = raw::c_long; |
|
|
|
|
|
type PHKEY = *mut HKEY; |
|
|
|
|
|
type PFILETIME = *mut u8; |
|
|
|
|
|
type LPBYTE = *mut u8; |
|
|
|
|
|
type REGSAM = u32; |
|
|
|
|
|
|
|
|
|
|
|
const ERROR_SUCCESS: DWORD = 0; |
|
|
|
|
|
const ERROR_NO_MORE_ITEMS: DWORD = 259; |
|
|
|
|
|
const HKEY_LOCAL_MACHINE: HKEY = 0x80000002 as HKEY; |
|
|
|
|
|
const REG_SZ: DWORD = 1; |
|
|
|
|
|
const KEY_READ: DWORD = 0x20019; |
|
|
|
|
|
const KEY_WOW64_32KEY: DWORD = 0x200; |
|
|
|
|
|
|
|
|
|
|
|
#[link(name = "advapi32")] |
|
|
|
|
|
extern "system" { |
|
|
|
|
|
fn RegOpenKeyExW(key: HKEY, |
|
|
|
|
|
lpSubKey: LPCWSTR, |
|
|
|
|
|
ulOptions: DWORD, |
|
|
|
|
|
samDesired: REGSAM, |
|
|
|
|
|
phkResult: PHKEY) -> LONG; |
|
|
|
|
|
fn RegEnumKeyExW(key: HKEY, |
|
|
|
|
|
dwIndex: DWORD, |
|
|
|
|
|
lpName: LPWSTR, |
|
|
|
|
|
lpcName: LPDWORD, |
|
|
|
|
|
lpReserved: LPDWORD, |
|
|
|
|
|
lpClass: LPWSTR, |
|
|
|
|
|
lpcClass: LPDWORD, |
|
|
|
|
|
lpftLastWriteTime: PFILETIME) -> LONG; |
|
|
|
|
|
fn RegQueryValueExW(hKey: HKEY, |
|
|
|
|
|
lpValueName: LPCWSTR, |
|
|
|
|
|
lpReserved: LPDWORD, |
|
|
|
|
|
lpType: LPDWORD, |
|
|
|
|
|
lpData: LPBYTE, |
|
|
|
|
|
lpcbData: LPDWORD) -> LONG; |
|
|
|
|
|
fn RegCloseKey(hKey: HKEY) -> LONG; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
struct OwnedKey(HKEY); |
|
|
struct OwnedKey(HKEY); |
|
|
|
|
|
|
|
|
enum Repr { |
|
|
enum Repr { |
|
|