Skip to content

Commit 9ef3d8d

Browse files
committed
win32
1 parent 2d15636 commit 9ef3d8d

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

lib/bencher_context/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ uuid = { workspace = true, optional = true, features = ["serde"] }
2323
[target.'cfg(target_os = "windows")'.dependencies]
2424
windows = { version = "0.60", optional = true, features = [
2525
"System_Profile_SystemManufacturers",
26+
"Win32",
2627
] }
2728

2829
[lints]

lib/bencher_context/src/client/platform/target_os/windows.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,13 @@ fn serial_number() -> Option<Uuid> {
2525
}
2626

2727
fn digital_product_id() -> Option<Uuid> {
28-
let sub_key = PCWSTR::from(
29-
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\0"
30-
.encode_utf16()
31-
.collect::<Vec<u16>>()
32-
.as_ptr(),
33-
);
28+
let key = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\0"
29+
.encode_utf16()
30+
.collect::<Vec<u16>>();
31+
let sub_key = PCWSTR::from_raw(key.as_ptr());
3432
let hkey = RegOpenKeyExW(HKEY_LOCAL_MACHINE, sub_key, 0, KEY_READ).ok()?;
35-
let value_name = PCWSTR::from(
36-
"DigitalProductId\0"
37-
.encode_utf16()
38-
.collect::<Vec<u16>>()
39-
.as_ptr(),
40-
);
33+
let value = "DigitalProductId\0".encode_utf16().collect::<Vec<u16>>();
34+
let value_name = PCWSTR::from_raw(value.as_ptr());
4135
let mut data = vec![0u8; 256];
4236
let mut data_size = data.len() as u32;
4337
RegQueryValueExW(

0 commit comments

Comments
 (0)