• Welcome to PlanetSquires Forums.
 

CPrint (SetPrinterInfo access error)

Started by Paul Squires, March 12, 2023, 03:45:01 PM

Previous topic - Next topic

Paul Squires

Hi José,

I was attempting to set some properties for the default printer but the settings would never update.

I debugged the problem to the SetPrinterInfo method and the "pd.DesiredAccess = PRINTER_ALL_ACCESS" line. It appears that maybe that level of security access is too strict as it keep throwing an Error 5 (ERROR_ACCESS_DENIED) for me.

I changed the value to PRINTER_ACCESS_USE (the same as passing NULL to OpenPrinter) and then the code worked perfectly and I was able to set settings like Orientation.

If you do not have a need for PRINTER_ALL_ACCESS that I don't know about, then maybe using PRINTER_ACCESS_USE would be sufficient?

Thanks,
Paul
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

Whatever works is fine with me. I don't even have a printer :) I had one, but it is broken.


Paul Squires

Thanks José, I see that you have committed the change to GitHub. Appreciate it. I am testing using a PDF printer until my code is mostly complete and then I will switch to some tests using my small Samsung laser printer (that mostly collects dust these days).
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer