Closed funArash closed 11 months ago
I tested your code, and it works perfectly for me.
What's your Windows version?
I have two Windows installs and it was reproducable on both x64 OS
Edition Windows 11 Enterprise
Version 22H2
Installed on 3/29/2023
OS build 22621.2715
Experience Windows Feature Experience Pack 1000.22677.1000.0
aarch64 OS
Edition Windows 11 Pro
Version 23H2
Installed on 7/11/2023
OS build 22631.2715
Experience Windows Feature Experience Pack 1000.22677.1000.0
https://github.com/funArash/winsafe/commit/9332457981fbc0d0bbe288ae811d03ffea652d24 this works.. it is the check of the data_lens that is causing it. no sure what is its root cause
Will the code below run?
fn main() {
use winsafe::{self as w, prelude::*, co};
let hkey = w::HKEY::CURRENT_USER.RegOpenKeyEx(
Some("Control Panel\\Mouse"),
co::REG_OPTION::default(),
co::KEY::READ,
).unwrap();
let val = hkey.RegQueryValueEx(Some("Beep")).unwrap();
match val {
w::RegistryValue::Dword(n) => println!("Number u32: {}", n),
w::RegistryValue::Qword(n) => println!("Number u64: {}", n),
w::RegistryValue::Sz(s) => println!("String: {}", s),
w::RegistryValue::ExpandSz(s) => {
println!("Env string: {}", w::ExpandEnvironmentStrings(&s).unwrap());
},
w::RegistryValue::MultiSz(strs) => {
println!("Multi string:");
for s in strs.iter() {
print!("[{}] ", s);
}
println!("");
},
w::RegistryValue::Binary(bin) => {
println!("Binary:");
for b in bin.iter() {
print!("{:02x} ", b);
}
println!("");
},
w::RegistryValue::None => println!("No value"),
}
}
it panics on line with let val = hkey.RegQueryValueEx(Some("Beep")).unwrap();
thread 'main' panicked at src\main.rs:12:50:
called `Result::unwrap()` on an `Err` value: [0x1a2e 6702] The requested operation is not valid on the Transaction object in its current state.```
My bad.. the test above was done against version 0.0.18..
using latest master (16f2119a56)
works fine with both my code and yours.
looks like this #103 is the fix.
Dude... this problem was driving me nuts. I was about to send you a Rust code with exposed raw bindings to find out what was wrong.
Good to know it's fine.
RegQueryValueEx returning TRANSACTION_REQUEST_NOT_VALID for what should be valid data in the registry.. no race conditions.
the following code reproduces the failures. using winsafe version 0.0.18 the registry variables such as
PROCESSOR_ARCHITECTURE
,PROCESSOR_IDENTIFIER
, andOS
(to list a few) are valid and should not error TRANSACTION_REQUEST_NOT_VALID.output