• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 451
  • Last Modified:

Printer Status using MFC or SDK ...

How do I get the status of the printer using MFC or SDK ? I should be able to see if the printer is active, idle, powered off etc.
0
ganeshokade
Asked:
ganeshokade
  • 3
1 Solution
 
jkrCommented:
Use 'OpenPrinter()' to retrieve a handle to the specified printer. Then call 'GetPrinter()' to request a PRINTER_INFO_*' (preferrably 'PRINTER_INFO_5') structure that holds the information the system 'knows' about the printer (e.g. 'PRINTER_ATTRIBUTE_WORK_OFFLINE' etc.)
0
 
jkrCommented:
Ooops - 'PRINTER_INFO_2' should work for you also, but you'll better take a look at all structures to find out what fits your needs better ;-)
0
 
plarocheCommented:
Two knowledge base articles will help you with this:

Q160129
Q158828

It would be pointless to repeat the articles here, they are well written and starting there can get you almost anything out of the print drivers/spoolers, etc...

To find those articles you can go to Microsoft's site in the search section. Click on the Knowledge Base radio button and search the article number.
0
 
ganeshokadeAuthor Commented:
I found both jkr's and plaroche's answer very helpful. But I have one small problem. The two articles quoted above mention that it is possible to get the physical printer status only if the spooler is sending a print job to the printer. Can you give me a trick by which I can get the physical printer status whenever I want to ?
0
 
jkrCommented:
Well, as the article states:
>>Consequently, a system Printer reports no status when the
>>Printer queue is empty
The easiest way to get around this would be to add a 'dummy' job to the queue before you retrieve the status and using 'SetJob( ..., JOB_CONTROL_CANCEL);' to delete it afterwards instead of calling 'ScheduleJob()'...
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now