Solved

Printer Status using MFC or SDK ...

Posted on 1998-12-23
5
385 Views
Last Modified: 2013-11-20
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
Comment
Question by:ganeshokade
  • 3
5 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 1326646
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
 
LVL 86

Expert Comment

by:jkr
ID: 1326647
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
 
LVL 3

Expert Comment

by:plaroche
ID: 1326648
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
 

Author Comment

by:ganeshokade
ID: 1326649
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
 
LVL 86

Expert Comment

by:jkr
ID: 1326650
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Creating an alias to a directory so I can change the directory 'contents' by changing the alias 5 86
sum67 challenge 35 102
sumHeights  challenge 17 71
mapBully challenge 6 136
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question