Link to home
Start Free TrialLog in
Avatar of Foo Zack
Foo Zack

asked on

Detect if “Pause Printing” option in Print Queue is checked

I am currently looking for a way to detect if the "Pause Printing" option in the "See What's Printing" window is checked in Windows.

I've searched high and low, and looked into the Win32 native printing API (winspool) to see if there was such a detection available, but to no avail.

Is there anyone who has experience with a successful implementation of this detection?

I'm looking for a solution in either C/C++, or C#.
Avatar of Zoppo
Zoppo
Flag of Germany image

Hi Foo Zack,

IMO it should be possible somehow like this:

First use OpenPrinter (see https://msdn.microsoft.com/de-de/library/windows/desktop/dd162751(v=vs.85).aspx) to retreive a handle to the used printer.

With the handle from above you can call GetJob (see https://msdn.microsoft.com/de-de/library/windows/desktop/dd144894(v=vs.85).aspx) to get info about a running print job - for this you need to know the job ID, this usually can be obtained when printing starts as return value of StartDoc (see https://msdn.microsoft.com/de-de/library/windows/desktop/dd145114(v=vs.85).aspx^).

With GetJob you can retrieve a JOB_INFO_1 which contains information about the print job, this struct has a member Status which is a combination of different status flags - you can check if the job is paused if '( Status & JOB_STATUS_PAUSED ) != 0'.

Hope this helps,

ZOPPO
Avatar of Foo Zack
Foo Zack

ASKER

Hi Zoppo,

Appreciate the help! But I think my question was perhaps worded incorrectly.

Your proposed solution gives me the pause state of the print job.
In this particular scenario, what I'm particularly interested in is if the print queue is paused.

Hopefully this illustration will make my question clearer:
User generated image
EDIT: Just to note, the print job and print queues' pause states are managed differently. If you were to set the print queue to paused, jobs that come in will not have a state assigned to it. It's paused in the screenshot because I set it to paused myself.
ASKER CERTIFIED SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Zoppo,

Alright, I'll give that a shot, must have missed that bit.

I'll reply again with the results :D
Hi Zoppo,

Thank you very much! It's working now!

Turns out I had implemented the enum and flags for PRINTER_ATTRIBUTES but not PRINTER_STATUS.

Thanks for pointing me in the right direction!

For those who are interested:

This will help you build your enum for PRINTER_ATTRIBUTES and PRINTER_STATUS:
https://msdn.microsoft.com/en-us/library/cc244854.aspx

This will help you build the structure for PRINTER_INFO_2:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd162845(v=vs.85).aspx
Gave a very helpful nod in the right direction!
Great, I'm glad I could help ...

Have a nice day,

best regards,

ZOPPO