473,394 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Detect if windows printer not responding

Hi All

I am using vb.net 2005 in a windows forms application

I send data to the selected windows printer using a PrintDocument object

Is there any way to detect if the Printer is not responding e.g turned off,
out of paper etc, via code

I want to display a warning if the printer needs attention rather than just
keep filling the Printer queue

Regards
Steve
Jun 27 '08 #1
1 4179
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/libr...82(VS.85).aspx
http://msdn.microsoft.com/en-us/libr...70(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:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Stephane Belzile | last post by:
Is there a way I can detect in vb.Net the power has switched to a UPS unit in case of power failure? Thanks
3
by: Dalan | last post by:
Perhaps someone has experienced this problem. I developed an Access 97 Runtime database on a Windows 98 SE machine. I have three reports that can be optionally copied to a floppy disk or hard drive...
54
by: Sathyaish | last post by:
I am trying to print to the printer. I am using a VC++ 6.0 compiler on Win 2K, but I get an error saying that stdprn is not defined. Why is that? Is it because of Windows, I am guessing? Do I have...
19
by: Frank Rizzo | last post by:
I want to log the user out when there has been a period of inactivity in the application. The key here is inactivity of the application, not the system. I know that you can retrieve the...
2
by: dever | last post by:
I checked my color printers's Printersettings.SupportsColor, which all showed false. What is wrong that I could not use this property. Also, what other way to detect if a printer is color...
4
by: ZS | last post by:
Hi, in c# how can one detect if a printer is connected to the computer or not. Thanks in advance -zs
3
by: printline | last post by:
Hello Guys I cannot print from a locally installed printer that is mapped to a windows 2003 sever. I have installed the printer locally and can print locally. I connect to the windows 2003...
4
by: Stefano | last post by:
I've got a problem using printer functions with my network printer shared on another PC as \\192.168.1.3\HP If the printer is connected and reachable, printer_***() functions work correctly. ...
2
by: wassimdaccache | last post by:
Dear all I am using windows server 2003 sp1. I am connecting a printer called BIRCH prp080 to my pc using the serial port. the printer is working well when I install the driver but the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.