MCPcopy Index your code
hub / github.com/RustPython/RustPython / SetValueEx

Function SetValueEx

crates/vm/src/stdlib/winreg.rs:1041–1064  ·  view source on GitHub ↗
(
        key: PyRef<PyHkey>,
        value_name: Option<String>,
        _reserved: PyObjectRef,
        typ: u32,
        value: PyObjectRef,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

1039
1040 #[pyfunction]
1041 fn SetValueEx(
1042 key: PyRef<PyHkey>,
1043 value_name: Option<String>,
1044 _reserved: PyObjectRef,
1045 typ: u32,
1046 value: PyObjectRef,
1047 vm: &VirtualMachine,
1048 ) -> PyResult<()> {
1049 let wide_value_name = value_name.as_deref().map(|s| s.to_wide_with_nul());
1050 let value_name_ptr = wide_value_name
1051 .as_deref()
1052 .map_or(core::ptr::null(), |s| s.as_ptr());
1053 let reg_value = py2reg(value, typ, vm)?;
1054 let (ptr, len) = match &reg_value {
1055 Some(v) => (v.as_ptr(), v.len() as u32),
1056 None => (core::ptr::null(), 0),
1057 };
1058 let res =
1059 unsafe { Registry::RegSetValueExW(key.hkey.load(), value_name_ptr, 0, typ, ptr, len) };
1060 if res != 0 {
1061 return Err(os_error_from_windows_code(vm, res as i32));
1062 }
1063 Ok(())
1064 }
1065
1066 #[pyfunction]
1067 fn DisableReflectionKey(key: PyRef<PyHkey>, vm: &VirtualMachine) -> PyResult<()> {

Calls 8

py2regFunction · 0.85
to_wide_with_nulMethod · 0.80
ErrClass · 0.50
mapMethod · 0.45
as_ptrMethod · 0.45
lenMethod · 0.45
loadMethod · 0.45