473,769 Members | 3,755 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4225
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.Manageme nt
assembly to your project.

Imports System.Manageme nt

Dim oq As New.ObjectQuery ("SELECT * FROM Win32_PrintJob" ) '
Dim query1 As New ManagementObjec tSearcher(oq)
Dim queryCollection 1 As ManagementObjec tCollection = query1.Get()
Dim mo As Management.Mana gementObject
For Each mo In queryCollection 1
Console.WriteLi ne(("Printer Driver : " + mo("DriverName" ).ToString()))
Console.WriteLi ne(("Document Name : " + mo("Document"). ToString()))
Console.WriteLi ne(("Document Owner : " + mo("Owner").ToS tring()))

If (mo("JobStatus" ) IsNot Nothing) Then
Console.WriteLi ne(("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****@microsof t.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
4017
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
2327
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 through use of a macro: Output To, Report, the name of the Report, Rich Text Format, Output location and file name, and Auto Start - No. The process has worked flawlessly when running the macro on Windows 98 SE under Access 97 SR2b on the host...
54
8997
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 to use only the GDI32 functions for printing under Windows? Can I not use the stdprn under Windows to print from memory to the window?
19
46685
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 inactivity of the system via GetLastInputInfo. That's not what I want - I want inactivity of the application. Thanks.
2
4605
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 printer. TIA
4
13122
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
2796
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 server by using remote desktop connection. i have checked the printer checkbox under local resources, so that it maps the printer when i connect. I can also see the printer on my printer list when i am logged on to the windows 2003 server, but when...
4
2034
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. Now let suppose the printer cable is unplagged so the printer is no more reachable: $handle = printer_open($printer_address); // Returns an handle also if the
2
3417
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 problem is when I restart the computer the printer won't work. Right click properties in my printer driver will show me the message below The prp-080 printer driver is not installed on this computer. Some properties will not be accessible unless...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9860
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5297
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5445
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3955
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.