Closed ValentinGrim closed 4 days ago
I think you just need to cast the byte pointer to a pointer of the appropriate structure. I'm not sure why you're casting it to an array/slice of structures. The API docs seem to indicate that it returns a single structure.
Actually, windows-rs is the first crate that I use that made me use raw pointer in Rust. I'm not actually into casting raw pointer and unsafe code in general. That's a discovery for me.
Anyway, I think you mean something like that, and it work that way so I post it if someone needs it.
let printer_info = std::ptr::slice_from_raw_parts(buffer.as_ptr(), buffer.len()) as *const PRINTER_INFO_2W;
Thanks
Summary
Hi,
I'm trying to get the printer info of a printer using GetPrinterW function but I'm stuck casting
PRINTER_INFO_2W
from raw [u8] buffer.I based my code on issue 2975 that's use EnumPrinters.
I have this (see last line comments):
Any help would be apreciated, thank's in advance. Have a nice day.
Crate manifest
No response
Crate code
No response