gecko-dev/third_party/rust/winreg
Andreas Tolfsen 13b488a19b Bug 1437571 - Bump winreg dependencies. r=jgraham
Made this a separate commit as it would be impossible to review otherwise.

MozReview-Commit-ID: GBsDQA4bMtF


--HG--
rename : third_party/rust/winapi/.cargo-checksum.json => third_party/rust/winapi-0.2.8/.cargo-checksum.json
rename : third_party/rust/winapi/Cargo.toml => third_party/rust/winapi-0.2.8/Cargo.toml
rename : third_party/rust/winapi/LICENSE.md => third_party/rust/winapi-0.2.8/LICENSE.md
rename : third_party/rust/winapi/src/activation.rs => third_party/rust/winapi-0.2.8/src/activation.rs
rename : third_party/rust/winapi/src/audioclient.rs => third_party/rust/winapi-0.2.8/src/audioclient.rs
rename : third_party/rust/winapi/src/audiosessiontypes.rs => third_party/rust/winapi-0.2.8/src/audiosessiontypes.rs
rename : third_party/rust/winapi/src/basetsd.rs => third_party/rust/winapi-0.2.8/src/basetsd.rs
rename : third_party/rust/winapi/src/bcrypt.rs => third_party/rust/winapi-0.2.8/src/bcrypt.rs
rename : third_party/rust/winapi/src/cfg.rs => third_party/rust/winapi-0.2.8/src/cfg.rs
rename : third_party/rust/winapi/src/cfgmgr32.rs => third_party/rust/winapi-0.2.8/src/cfgmgr32.rs
rename : third_party/rust/winapi/src/combaseapi.rs => third_party/rust/winapi-0.2.8/src/combaseapi.rs
rename : third_party/rust/winapi/src/commctrl.rs => third_party/rust/winapi-0.2.8/src/commctrl.rs
rename : third_party/rust/winapi/src/commdlg.rs => third_party/rust/winapi-0.2.8/src/commdlg.rs
rename : third_party/rust/winapi/src/corsym.rs => third_party/rust/winapi-0.2.8/src/corsym.rs
rename : third_party/rust/winapi/src/d2d1.rs => third_party/rust/winapi-0.2.8/src/d2d1.rs
rename : third_party/rust/winapi/src/d2dbasetypes.rs => third_party/rust/winapi-0.2.8/src/d2dbasetypes.rs
rename : third_party/rust/winapi/src/d3d10shader.rs => third_party/rust/winapi-0.2.8/src/d3d10shader.rs
rename : third_party/rust/winapi/src/d3d11.rs => third_party/rust/winapi-0.2.8/src/d3d11.rs
rename : third_party/rust/winapi/src/d3d11shader.rs => third_party/rust/winapi-0.2.8/src/d3d11shader.rs
rename : third_party/rust/winapi/src/d3d12.rs => third_party/rust/winapi-0.2.8/src/d3d12.rs
rename : third_party/rust/winapi/src/d3d12sdklayers.rs => third_party/rust/winapi-0.2.8/src/d3d12sdklayers.rs
rename : third_party/rust/winapi/src/d3d12shader.rs => third_party/rust/winapi-0.2.8/src/d3d12shader.rs
rename : third_party/rust/winapi/src/d3d9.rs => third_party/rust/winapi-0.2.8/src/d3d9.rs
rename : third_party/rust/winapi/src/d3d9caps.rs => third_party/rust/winapi-0.2.8/src/d3d9caps.rs
rename : third_party/rust/winapi/src/d3d9types.rs => third_party/rust/winapi-0.2.8/src/d3d9types.rs
rename : third_party/rust/winapi/src/d3dcommon.rs => third_party/rust/winapi-0.2.8/src/d3dcommon.rs
rename : third_party/rust/winapi/src/d3dcompiler.rs => third_party/rust/winapi-0.2.8/src/d3dcompiler.rs
rename : third_party/rust/winapi/src/dbghelp.rs => third_party/rust/winapi-0.2.8/src/dbghelp.rs
rename : third_party/rust/winapi/src/dcommon.rs => third_party/rust/winapi-0.2.8/src/dcommon.rs
rename : third_party/rust/winapi/src/devpropdef.rs => third_party/rust/winapi-0.2.8/src/devpropdef.rs
rename : third_party/rust/winapi/src/docobj.rs => third_party/rust/winapi-0.2.8/src/docobj.rs
rename : third_party/rust/winapi/src/dpapi.rs => third_party/rust/winapi-0.2.8/src/dpapi.rs
rename : third_party/rust/winapi/src/dsgetdc.rs => third_party/rust/winapi-0.2.8/src/dsgetdc.rs
rename : third_party/rust/winapi/src/dsound.rs => third_party/rust/winapi-0.2.8/src/dsound.rs
rename : third_party/rust/winapi/src/dsrole.rs => third_party/rust/winapi-0.2.8/src/dsrole.rs
rename : third_party/rust/winapi/src/dwmapi.rs => third_party/rust/winapi-0.2.8/src/dwmapi.rs
rename : third_party/rust/winapi/src/dwrite.rs => third_party/rust/winapi-0.2.8/src/dwrite.rs
rename : third_party/rust/winapi/src/dxgi.rs => third_party/rust/winapi-0.2.8/src/dxgi.rs
rename : third_party/rust/winapi/src/dxgi1_2.rs => third_party/rust/winapi-0.2.8/src/dxgi1_2.rs
rename : third_party/rust/winapi/src/dxgi1_3.rs => third_party/rust/winapi-0.2.8/src/dxgi1_3.rs
rename : third_party/rust/winapi/src/dxgi1_4.rs => third_party/rust/winapi-0.2.8/src/dxgi1_4.rs
rename : third_party/rust/winapi/src/dxgiformat.rs => third_party/rust/winapi-0.2.8/src/dxgiformat.rs
rename : third_party/rust/winapi/src/dxgitype.rs => third_party/rust/winapi-0.2.8/src/dxgitype.rs
rename : third_party/rust/winapi/src/errhandlingapi.rs => third_party/rust/winapi-0.2.8/src/errhandlingapi.rs
rename : third_party/rust/winapi/src/excpt.rs => third_party/rust/winapi-0.2.8/src/excpt.rs
rename : third_party/rust/winapi/src/fileapi.rs => third_party/rust/winapi-0.2.8/src/fileapi.rs
rename : third_party/rust/winapi/src/gl.rs => third_party/rust/winapi-0.2.8/src/gl.rs
rename : third_party/rust/winapi/src/guiddef.rs => third_party/rust/winapi-0.2.8/src/guiddef.rs
rename : third_party/rust/winapi/src/heapapi.rs => third_party/rust/winapi-0.2.8/src/heapapi.rs
rename : third_party/rust/winapi/src/hidclass.rs => third_party/rust/winapi-0.2.8/src/hidclass.rs
rename : third_party/rust/winapi/src/hidpi.rs => third_party/rust/winapi-0.2.8/src/hidpi.rs
rename : third_party/rust/winapi/src/hidsdi.rs => third_party/rust/winapi-0.2.8/src/hidsdi.rs
rename : third_party/rust/winapi/src/hidusage.rs => third_party/rust/winapi-0.2.8/src/hidusage.rs
rename : third_party/rust/winapi/src/hstring.rs => third_party/rust/winapi-0.2.8/src/hstring.rs
rename : third_party/rust/winapi/src/http.rs => third_party/rust/winapi-0.2.8/src/http.rs
rename : third_party/rust/winapi/src/imm.rs => third_party/rust/winapi-0.2.8/src/imm.rs
rename : third_party/rust/winapi/src/inaddr.rs => third_party/rust/winapi-0.2.8/src/inaddr.rs
rename : third_party/rust/winapi/src/inspectable.rs => third_party/rust/winapi-0.2.8/src/inspectable.rs
rename : third_party/rust/winapi/src/ksmedia.rs => third_party/rust/winapi-0.2.8/src/ksmedia.rs
rename : third_party/rust/winapi/src/lib.rs => third_party/rust/winapi-0.2.8/src/lib.rs
rename : third_party/rust/winapi/src/libloaderapi.rs => third_party/rust/winapi-0.2.8/src/libloaderapi.rs
rename : third_party/rust/winapi/src/lmaccess.rs => third_party/rust/winapi-0.2.8/src/lmaccess.rs
rename : third_party/rust/winapi/src/lmcons.rs => third_party/rust/winapi-0.2.8/src/lmcons.rs
rename : third_party/rust/winapi/src/lmdfs.rs => third_party/rust/winapi-0.2.8/src/lmdfs.rs
rename : third_party/rust/winapi/src/lmerrlog.rs => third_party/rust/winapi-0.2.8/src/lmerrlog.rs
rename : third_party/rust/winapi/src/lmjoin.rs => third_party/rust/winapi-0.2.8/src/lmjoin.rs
rename : third_party/rust/winapi/src/lsalookup.rs => third_party/rust/winapi-0.2.8/src/lsalookup.rs
rename : third_party/rust/winapi/src/macros.rs => third_party/rust/winapi-0.2.8/src/macros.rs
rename : third_party/rust/winapi/src/memoryapi.rs => third_party/rust/winapi-0.2.8/src/memoryapi.rs
rename : third_party/rust/winapi/src/minschannel.rs => third_party/rust/winapi-0.2.8/src/minschannel.rs
rename : third_party/rust/winapi/src/minwinbase.rs => third_party/rust/winapi-0.2.8/src/minwinbase.rs
rename : third_party/rust/winapi/src/minwindef.rs => third_party/rust/winapi-0.2.8/src/minwindef.rs
rename : third_party/rust/winapi/src/mmdeviceapi.rs => third_party/rust/winapi-0.2.8/src/mmdeviceapi.rs
rename : third_party/rust/winapi/src/mmreg.rs => third_party/rust/winapi-0.2.8/src/mmreg.rs
rename : third_party/rust/winapi/src/mmsystem.rs => third_party/rust/winapi-0.2.8/src/mmsystem.rs
rename : third_party/rust/winapi/src/mscat.rs => third_party/rust/winapi-0.2.8/src/mscat.rs
rename : third_party/rust/winapi/src/mssip.rs => third_party/rust/winapi-0.2.8/src/mssip.rs
rename : third_party/rust/winapi/src/nb30.rs => third_party/rust/winapi-0.2.8/src/nb30.rs
rename : third_party/rust/winapi/src/ncrypt.rs => third_party/rust/winapi-0.2.8/src/ncrypt.rs
rename : third_party/rust/winapi/src/ntdef.rs => third_party/rust/winapi-0.2.8/src/ntdef.rs
rename : third_party/rust/winapi/src/ntsecapi.rs => third_party/rust/winapi-0.2.8/src/ntsecapi.rs
rename : third_party/rust/winapi/src/ntstatus.rs => third_party/rust/winapi-0.2.8/src/ntstatus.rs
rename : third_party/rust/winapi/src/oaidl.rs => third_party/rust/winapi-0.2.8/src/oaidl.rs
rename : third_party/rust/winapi/src/objbase.rs => third_party/rust/winapi-0.2.8/src/objbase.rs
rename : third_party/rust/winapi/src/objidl.rs => third_party/rust/winapi-0.2.8/src/objidl.rs
rename : third_party/rust/winapi/src/objidlbase.rs => third_party/rust/winapi-0.2.8/src/objidlbase.rs
rename : third_party/rust/winapi/src/olectl.rs => third_party/rust/winapi-0.2.8/src/olectl.rs
rename : third_party/rust/winapi/src/pdh.rs => third_party/rust/winapi-0.2.8/src/pdh.rs
rename : third_party/rust/winapi/src/playsoundapi.rs => third_party/rust/winapi-0.2.8/src/playsoundapi.rs
rename : third_party/rust/winapi/src/processsnapshot.rs => third_party/rust/winapi-0.2.8/src/processsnapshot.rs
rename : third_party/rust/winapi/src/processthreadsapi.rs => third_party/rust/winapi-0.2.8/src/processthreadsapi.rs
rename : third_party/rust/winapi/src/propidl.rs => third_party/rust/winapi-0.2.8/src/propidl.rs
rename : third_party/rust/winapi/src/propsys.rs => third_party/rust/winapi-0.2.8/src/propsys.rs
rename : third_party/rust/winapi/src/prsht.rs => third_party/rust/winapi-0.2.8/src/prsht.rs
rename : third_party/rust/winapi/src/psapi.rs => third_party/rust/winapi-0.2.8/src/psapi.rs
rename : third_party/rust/winapi/src/qos.rs => third_party/rust/winapi-0.2.8/src/qos.rs
rename : third_party/rust/winapi/src/reason.rs => third_party/rust/winapi-0.2.8/src/reason.rs
rename : third_party/rust/winapi/src/restrictederrorinfo.rs => third_party/rust/winapi-0.2.8/src/restrictederrorinfo.rs
rename : third_party/rust/winapi/src/roapi.rs => third_party/rust/winapi-0.2.8/src/roapi.rs
rename : third_party/rust/winapi/src/roerrorapi.rs => third_party/rust/winapi-0.2.8/src/roerrorapi.rs
rename : third_party/rust/winapi/src/rpc.rs => third_party/rust/winapi-0.2.8/src/rpc.rs
rename : third_party/rust/winapi/src/rpcdce.rs => third_party/rust/winapi-0.2.8/src/rpcdce.rs
rename : third_party/rust/winapi/src/sapi.rs => third_party/rust/winapi-0.2.8/src/sapi.rs
rename : third_party/rust/winapi/src/schannel.rs => third_party/rust/winapi-0.2.8/src/schannel.rs
rename : third_party/rust/winapi/src/servprov.rs => third_party/rust/winapi-0.2.8/src/servprov.rs
rename : third_party/rust/winapi/src/setupapi.rs => third_party/rust/winapi-0.2.8/src/setupapi.rs
rename : third_party/rust/winapi/src/shellapi.rs => third_party/rust/winapi-0.2.8/src/shellapi.rs
rename : third_party/rust/winapi/src/shellscalingapi.rs => third_party/rust/winapi-0.2.8/src/shellscalingapi.rs
rename : third_party/rust/winapi/src/shlguid.rs => third_party/rust/winapi-0.2.8/src/shlguid.rs
rename : third_party/rust/winapi/src/shlobj.rs => third_party/rust/winapi-0.2.8/src/shlobj.rs
rename : third_party/rust/winapi/src/shobjidl.rs => third_party/rust/winapi-0.2.8/src/shobjidl.rs
rename : third_party/rust/winapi/src/shtypes.rs => third_party/rust/winapi-0.2.8/src/shtypes.rs
rename : third_party/rust/winapi/src/spapidef.rs => third_party/rust/winapi-0.2.8/src/spapidef.rs
rename : third_party/rust/winapi/src/sql.rs => third_party/rust/winapi-0.2.8/src/sql.rs
rename : third_party/rust/winapi/src/sqltypes.rs => third_party/rust/winapi-0.2.8/src/sqltypes.rs
rename : third_party/rust/winapi/src/sspi.rs => third_party/rust/winapi-0.2.8/src/sspi.rs
rename : third_party/rust/winapi/src/strmif.rs => third_party/rust/winapi-0.2.8/src/strmif.rs
rename : third_party/rust/winapi/src/subauth.rs => third_party/rust/winapi-0.2.8/src/subauth.rs
rename : third_party/rust/winapi/src/synchapi.rs => third_party/rust/winapi-0.2.8/src/synchapi.rs
rename : third_party/rust/winapi/src/sysinfoapi.rs => third_party/rust/winapi-0.2.8/src/sysinfoapi.rs
rename : third_party/rust/winapi/src/threadpoolapi.rs => third_party/rust/winapi-0.2.8/src/threadpoolapi.rs
rename : third_party/rust/winapi/src/timezoneapi.rs => third_party/rust/winapi-0.2.8/src/timezoneapi.rs
rename : third_party/rust/winapi/src/tlhelp32.rs => third_party/rust/winapi-0.2.8/src/tlhelp32.rs
rename : third_party/rust/winapi/src/unknwnbase.rs => third_party/rust/winapi-0.2.8/src/unknwnbase.rs
rename : third_party/rust/winapi/src/urlhist.rs => third_party/rust/winapi-0.2.8/src/urlhist.rs
rename : third_party/rust/winapi/src/urlmon.rs => third_party/rust/winapi-0.2.8/src/urlmon.rs
rename : third_party/rust/winapi/src/usb.rs => third_party/rust/winapi-0.2.8/src/usb.rs
rename : third_party/rust/winapi/src/usbspec.rs => third_party/rust/winapi-0.2.8/src/usbspec.rs
rename : third_party/rust/winapi/src/usp10.rs => third_party/rust/winapi-0.2.8/src/usp10.rs
rename : third_party/rust/winapi/src/vadefs.rs => third_party/rust/winapi-0.2.8/src/vadefs.rs
rename : third_party/rust/winapi/src/vsbackup.rs => third_party/rust/winapi-0.2.8/src/vsbackup.rs
rename : third_party/rust/winapi/src/vss.rs => third_party/rust/winapi-0.2.8/src/vss.rs
rename : third_party/rust/winapi/src/vsserror.rs => third_party/rust/winapi-0.2.8/src/vsserror.rs
rename : third_party/rust/winapi/src/vswriter.rs => third_party/rust/winapi-0.2.8/src/vswriter.rs
rename : third_party/rust/winapi/src/werapi.rs => third_party/rust/winapi-0.2.8/src/werapi.rs
rename : third_party/rust/winapi/src/winbase.rs => third_party/rust/winapi-0.2.8/src/winbase.rs
rename : third_party/rust/winapi/src/wincon.rs => third_party/rust/winapi-0.2.8/src/wincon.rs
rename : third_party/rust/winapi/src/wincred.rs => third_party/rust/winapi-0.2.8/src/wincred.rs
rename : third_party/rust/winapi/src/wincrypt.rs => third_party/rust/winapi-0.2.8/src/wincrypt.rs
rename : third_party/rust/winapi/src/windef.rs => third_party/rust/winapi-0.2.8/src/windef.rs
rename : third_party/rust/winapi/src/windowscodecs.rs => third_party/rust/winapi-0.2.8/src/windowscodecs.rs
rename : third_party/rust/winapi/src/windowsx.rs => third_party/rust/winapi-0.2.8/src/windowsx.rs
rename : third_party/rust/winapi/src/winerror.rs => third_party/rust/winapi-0.2.8/src/winerror.rs
rename : third_party/rust/winapi/src/winevt.rs => third_party/rust/winapi-0.2.8/src/winevt.rs
rename : third_party/rust/winapi/src/wingdi.rs => third_party/rust/winapi-0.2.8/src/wingdi.rs
rename : third_party/rust/winapi/src/winhttp.rs => third_party/rust/winapi-0.2.8/src/winhttp.rs
rename : third_party/rust/winapi/src/winioctl.rs => third_party/rust/winapi-0.2.8/src/winioctl.rs
rename : third_party/rust/winapi/src/winnetwk.rs => third_party/rust/winapi-0.2.8/src/winnetwk.rs
rename : third_party/rust/winapi/src/winnls.rs => third_party/rust/winapi-0.2.8/src/winnls.rs
rename : third_party/rust/winapi/src/winnt.rs => third_party/rust/winapi-0.2.8/src/winnt.rs
rename : third_party/rust/winapi/src/winreg.rs => third_party/rust/winapi-0.2.8/src/winreg.rs
rename : third_party/rust/winapi/src/winscard.rs => third_party/rust/winapi-0.2.8/src/winscard.rs
rename : third_party/rust/winapi/src/winsmcrd.rs => third_party/rust/winapi-0.2.8/src/winsmcrd.rs
rename : third_party/rust/winapi/src/winsock2.rs => third_party/rust/winapi-0.2.8/src/winsock2.rs
rename : third_party/rust/winapi/src/winspool.rs => third_party/rust/winapi-0.2.8/src/winspool.rs
rename : third_party/rust/winapi/src/winstring.rs => third_party/rust/winapi-0.2.8/src/winstring.rs
rename : third_party/rust/winapi/src/winsvc.rs => third_party/rust/winapi-0.2.8/src/winsvc.rs
rename : third_party/rust/winapi/src/winusb.rs => third_party/rust/winapi-0.2.8/src/winusb.rs
rename : third_party/rust/winapi/src/winusbio.rs => third_party/rust/winapi-0.2.8/src/winusbio.rs
rename : third_party/rust/winapi/src/winuser.rs => third_party/rust/winapi-0.2.8/src/winuser.rs
rename : third_party/rust/winapi/src/ws2def.rs => third_party/rust/winapi-0.2.8/src/ws2def.rs
rename : third_party/rust/winapi/src/ws2ipdef.rs => third_party/rust/winapi-0.2.8/src/ws2ipdef.rs
rename : third_party/rust/winapi/src/ws2spi.rs => third_party/rust/winapi-0.2.8/src/ws2spi.rs
rename : third_party/rust/winapi/src/ws2tcpip.rs => third_party/rust/winapi-0.2.8/src/ws2tcpip.rs
rename : third_party/rust/winapi/src/wtypes.rs => third_party/rust/winapi-0.2.8/src/wtypes.rs
rename : third_party/rust/winapi/src/wtypesbase.rs => third_party/rust/winapi-0.2.8/src/wtypesbase.rs
rename : third_party/rust/winapi/src/xinput.rs => third_party/rust/winapi-0.2.8/src/xinput.rs
rename : third_party/rust/winreg/examples/transaction.rs => third_party/rust/winreg/examples/transactions.rs
2018-02-14 20:48:26 +00:00
..
examples Bug 1437571 - Bump winreg dependencies. r=jgraham 2018-02-14 20:48:26 +00:00
src Bug 1437571 - Bump winreg dependencies. r=jgraham 2018-02-14 20:48:26 +00:00
.cargo-checksum.json Bug 1437571 - Bump winreg dependencies. r=jgraham 2018-02-14 20:48:26 +00:00
Cargo.toml Bug 1437571 - Bump winreg dependencies. r=jgraham 2018-02-14 20:48:26 +00:00
LICENSE
README.md Bug 1437571 - Bump winreg dependencies. r=jgraham 2018-02-14 20:48:26 +00:00
appveyor.yml Bug 1437571 - Bump winreg dependencies. r=jgraham 2018-02-14 20:48:26 +00:00

README.md

winreg Crates.io Build status

Rust bindings to MS Windows Registry API. Work in progress.

Current features:

  • Basic registry operations:
    • open/create/delete keys
    • read and write values
    • seamless conversion between REG_* types and rust primitives
      • String and OsString <= REG_SZ, REG_EXPAND_SZ or REG_MULTI_SZ
      • String, &str and OsStr => REG_SZ
      • u32 <=> REG_DWORD
      • u64 <=> REG_QWORD
  • Iteration through key names and through values
  • Transactions
  • Transacted serialization of rust types into/from registry (only primitives and structures for now)

Usage

Basic usage

# Cargo.toml
[dependencies]
winreg = "0.5"
extern crate winreg;
use std::path::Path;
use std::io;
use winreg::RegKey;
use winreg::enums::*;

fn main() {
    println!("Reading some system info...");
    let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
    let cur_ver = hklm.open_subkey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion").unwrap();
    let pf: String = cur_ver.get_value("ProgramFilesDir").unwrap();
    let dp: String = cur_ver.get_value("DevicePath").unwrap();
    println!("ProgramFiles = {}\nDevicePath = {}", pf, dp);
    let info = cur_ver.query_info().unwrap();
    println!("info = {:?}", info);

    println!("And now lets write something...");
    let hkcu = RegKey::predef(HKEY_CURRENT_USER);
    let path = Path::new("Software").join("WinregRsExample1");
    let key = hkcu.create_subkey(&path).unwrap();

    key.set_value("TestSZ", &"written by Rust").unwrap();
    let sz_val: String = key.get_value("TestSZ").unwrap();
    key.delete_value("TestSZ").unwrap();
    println!("TestSZ = {}", sz_val);

    key.set_value("TestDWORD", &1234567890u32).unwrap();
    let dword_val: u32 = key.get_value("TestDWORD").unwrap();
    println!("TestDWORD = {}", dword_val);

    key.set_value("TestQWORD", &1234567891011121314u64).unwrap();
    let qword_val: u64 = key.get_value("TestQWORD").unwrap();
    println!("TestQWORD = {}", qword_val);

    key.create_subkey("sub\\key").unwrap();
    hkcu.delete_subkey_all(&path).unwrap();

    println!("Trying to open nonexistent key...");
    let key2 = hkcu.open_subkey(&path)
    .unwrap_or_else(|e| match e.kind() {
        io::ErrorKind::NotFound => panic!("Key doesn't exist"),
        io::ErrorKind::PermissionDenied => panic!("Access denied"),
        _ => panic!("{:?}", e)
    });
}

Iterators

extern crate winreg;
use winreg::RegKey;
use winreg::enums::*;

fn main() {
    println!("File extensions, registered in system:");
    for i in RegKey::predef(HKEY_CLASSES_ROOT)
        .enum_keys().map(|x| x.unwrap())
        .filter(|x| x.starts_with("."))
    {
        println!("{}", i);
    }

    let system = RegKey::predef(HKEY_LOCAL_MACHINE)
        .open_subkey("HARDWARE\\DESCRIPTION\\System")
        .unwrap();
    for (name, value) in system.enum_values().map(|x| x.unwrap()) {
        println!("{} = {:?}", name, value);
    }
}

Transactions

# Cargo.toml
[dependencies]
winreg = { version = "0.5", features = ["transactions"] }
extern crate winreg;
use std::io;
use winreg::RegKey;
use winreg::enums::*;
use winreg::transaction::Transaction;

fn main() {
    let t = Transaction::new().unwrap();
    let hkcu = RegKey::predef(HKEY_CURRENT_USER);
    let key = hkcu.create_subkey_transacted("Software\\RustTransaction", &t).unwrap();
    key.set_value("TestQWORD", &1234567891011121314u64).unwrap();
    key.set_value("TestDWORD", &1234567890u32).unwrap();

    println!("Commit transaction? [y/N]:");
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input = input.trim_right().to_owned();
    if input == "y" || input == "Y" {
        t.commit().unwrap();
        println!("Transaction committed.");
    }
    else {
        // this is optional, if transaction wasn't committed,
        // it will be rolled back on disposal
        t.rollback().unwrap();

        println!("Transaction wasn't committed, it will be rolled back.");
    }
}

Serialization

# Cargo.toml
[dependencies]
winreg = { version = "0.5", features = ["serialization-serde"] }
serde = "1"
serde_derive = "1"
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate winreg;
use winreg::enums::*;

#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct Rectangle{
    x: u32,
    y: u32,
    w: u32,
    h: u32,
}

#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct Test {
    t_bool: bool,
    t_u8: u8,
    t_u16: u16,
    t_u32: u32,
    t_u64: u64,
    t_usize: usize,
    t_struct: Rectangle,
    t_string: String,
    t_i8: i8,
    t_i16: i16,
    t_i32: i32,
    t_i64: i64,
    t_isize: isize,
    t_f64: f64,
    t_f32: f32,
}

fn main() {
    let hkcu = winreg::RegKey::predef(HKEY_CURRENT_USER);
    let key = hkcu.create_subkey("Software\\RustEncode").unwrap();
    let v1 = Test{
        t_bool: false,
        t_u8: 127,
        t_u16: 32768,
        t_u32: 123456789,
        t_u64: 123456789101112,
        t_usize: 123456789101112,
        t_struct: Rectangle{
            x: 55,
            y: 77,
            w: 500,
            h: 300,
        },
        t_string: "test 123!".to_owned(),
        t_i8: -123,
        t_i16: -2049,
        t_i32: 20100,
        t_i64: -12345678910,
        t_isize: -1234567890,
        t_f64: -0.01,
        t_f32: 3.14,
    };

    key.encode(&v1).unwrap();

    let v2: Test = key.decode().unwrap();
    println!("Decoded {:?}", v2);

    // This shows `false` because f32 and f64 encoding/decoding is NOT precise
    println!("Equal to encoded: {:?}", v1 == v2);
}

Changelog

0.5.0

  • Breaking change: open_subkey now opens a key with readonly permissions. Use create_subkey or open_subkey_with_flags to open with read-write permissins.
  • Breaking change: features transactions and serialization-serde are now disabled by default.
  • Breaking change: serialization now uses serde instead of rustc-serialize.
  • winreg updated to 0.3.
  • Documentation fixes (#14)

0.4.0

  • Make transactions and serialization otional features
  • Update dependensies + minor fixes (#12)

0.3.5

  • Implement FromRegValue for OsString and ToRegValue for OsStr (#8)
  • Minor fixes

0.3.4

  • Add copy_tree method to RegKey
  • Now checked with rust-clippy
    • no more unwraps
    • replaced to_string with to_owned
  • Fix: reading strings longer than 2048 characters (#6)

0.3.3

  • Fix: now able to read values longer than 2048 bytes (#3)

0.3.2

  • Fix: FromRegValue trait now requires Sized (fixes build with rust 1.4)

0.3.1

  • Fix: bump winapi version to fix build

0.3.0

  • Add transactions support and make serialization transacted
  • Breaking change: use std::io::{Error,Result} instead of own RegError and RegResult