PlanetSquires Forums

Support Forums => WinFBX - Windows Framework for FreeBASIC => Topic started by: Paul Squires on March 12, 2023, 03:45:01 PM

Title: CPrint (SetPrinterInfo access error)
Post by: Paul Squires on March 12, 2023, 03:45:01 PM
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
Title: Re: CPrint (SetPrinterInfo access error)
Post by: José Roca on March 12, 2023, 08:25:48 PM
Whatever works is fine with me. I don't even have a printer :) I had one, but it is broken.

Title: Re: CPrint (SetPrinterInfo access error)
Post by: Paul Squires on March 12, 2023, 10:04:36 PM
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).