| 337 | |
| 338 | #[pyfunction] |
| 339 | fn CreateKeyEx(args: CreateKeyExArgs, vm: &VirtualMachine) -> PyResult<PyHkey> { |
| 340 | let wide_sub_key = args.sub_key.to_wide_with_nul(); |
| 341 | let mut res: Registry::HKEY = core::ptr::null_mut(); |
| 342 | let err = unsafe { |
| 343 | let key = args.key.hkey.load(); |
| 344 | Registry::RegCreateKeyExW( |
| 345 | key, |
| 346 | wide_sub_key.as_ptr(), |
| 347 | args.reserved, |
| 348 | core::ptr::null(), |
| 349 | Registry::REG_OPTION_NON_VOLATILE, |
| 350 | args.access, |
| 351 | core::ptr::null(), |
| 352 | &mut res, |
| 353 | core::ptr::null_mut(), |
| 354 | ) |
| 355 | }; |
| 356 | if err == 0 { |
| 357 | Ok(PyHkey { |
| 358 | #[allow(clippy::arc_with_non_send_sync)] |
| 359 | hkey: AtomicHKEY::new(res), |
| 360 | }) |
| 361 | } else { |
| 362 | Err(vm.new_os_error(format!("error code: {err}"))) |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | #[pyfunction] |
| 367 | fn CloseKey(hkey: PyRef<PyHkey>, vm: &VirtualMachine) -> PyResult<()> { |