I am trying to print from rust using winapi functions OpenPrinterA & StartDocPrinterA and windows crate.
I think I need these two functions to be able to print successfully.
The OpenPrinterA function is necessary to get the printer handle and the StartDocPrinter function to print. Please correct me if I am wrong.
I have difficulties calling up the functions correctly:
use windows::{core::PCSTR, Win32::{Foundation::HANDLE, Graphics::Printing::{OpenPrinterA, StartDocPrinterA}}};
let name = PCSTR::from_raw("My Printer".as_ptr());
let mut handle = // ?
let default = None; // Do I really need this?
OpenPrinterA(name, handle, default)
let handle = // ? Handle from previous call
let level = 1; // DOC_INFO_1
let doc = // ?
StartDocPrinterA(handle, level, doc)
The file to be printed is downloaded and does not exist on the HDD. However, it is no problem to save it temporarily on the HDD if necessary.
I am grateful for any help.
e-Ra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.