Hi Steve,
The status of printers and print jobs are updated by the Win32 Spooler
during the de-spool of a print job. All other time, when that printer is
not de-spooling and reports no state information, the printer is considered
to be ready and idle. It means that if there's no print job in the print
queue, we have no way to get the real status of the physical printer.
To determine the state of a physical printer, there is one fundamental
premise that must be true: the Spooler must be attempting to send a print
job to the physical printer. This is the only time the state of the printer
is reported by the port monitor. In addition, the most meaningful
information may be reported in the status members of a JOB_INFO structure
for that particular print job because some port monitor will have set these
values directly.
For more information on how to get the status of a printer and a print job,
you may refer to the following KB article:
'How to get the status of a printer and a print job'
http://support.microsoft.com/kb/160129/en-us
Alternatively, we can use WMI to get the status of a print job. WMI allows
us to retrieve large amount of system information including print jobs
information using a query-like syntax. To retrieve the print status
information, we can query the Win32_PrintJob class. The following is a
sample. It requires that you add a reference to the System.Management
assembly to your project.
Imports System.Management
Dim oq As New.ObjectQuery("SELECT * FROM Win32_PrintJob") '
Dim query1 As New ManagementObjectSearcher(oq)
Dim queryCollection1 As ManagementObjectCollection = query1.Get()
Dim mo As Management.ManagementObject
For Each mo In queryCollection1
Console.WriteLine(("Printer Driver : " + mo("DriverName").ToString()))
Console.WriteLine(("Document Name : " + mo("Document").ToString()))
Console.WriteLine(("Document Owner : " + mo("Owner").ToString()))
If (mo("JobStatus") IsNot Nothing) Then
Console.WriteLine(("Job Status : " + mo("JobStatus").ToString()))
End If
Next mo
For more information about WMI and WIN32_PrintJob class, please refer to
the following MSDN documents:
http://msdn.microsoft.com/en-us/library/aa394582(VS.85).aspx
http://msdn.microsoft.com/en-us/library/aa394370(VS.85).aspx
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.