472,110 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Check Printer Status??? How??

Hi,
I'm trying to select a printer in the system printers collection. I'm able
to do this.

However, if the printer is a network printer and happens that this printer
is not on or not ready, I won't be able to know and I try to print a
document I will get an error.

Is there anyway that I can check the status for the printer that the user
select is ready or not?

Regards
Vanessa
Nov 20 '05 #1
1 17647
* "Vanessa" <va*****@eclinic.com.sg> scripsit:
I'm trying to select a printer in the system printers collection. I'm able
to do this.

However, if the printer is a network printer and happens that this printer
is not on or not ready, I won't be able to know and I try to print a
document I will get an error.

Is there anyway that I can check the status for the printer that the user
select is ready or not?


\\\
Private Enum PrinterStatus
PrinterIdle = 3
PrinterPrinting = 4
PrinterWarmingUp = 5
' For more states see WMI docs.
End Enum

Private Function PrinterStatusToString(ByVal ps As PrinterStatus) As
String
Dim s As String
Select Case ps
Case PrinterStatus.PrinterIdle
s = "waiting (idle)"
Case PrinterStatus.PrinterPrinting
s = "printing"
Case PrinterStatus.PrinterWarmingUp
s = "warming up"
Case Else ' Vielleicht gibt es noch weitere Fälle...
s = "unknown state"
End Select
PrinterStatusToString = s
End Function

Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles MyBase.Load
Dim strPrintServer As String
strPrintServer = "localhost"
Dim WMIObject As String, PrinterSet As Object, Printer As Object
WMIObject = "winmgmts://" & strPrintServer
PrinterSet = GetObject(WMIObject).InstancesOf("win32_Printer")
For Each Printer In PrinterSet
MsgBox( _
Printer.Name & ": " & _
PrinterStatusToString(Printer.PrinterStatus) _
)
Next Printer
End Sub
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by rbt | last post: by
reply views Thread by Vanessa | last post: by
reply views Thread by Gordon Truslove | last post: by
3 posts views Thread by Gordon Truslove | last post: by
6 posts views Thread by Pipo | last post: by
2 posts views Thread by up3umrmuofnz3pd | last post: by
2 posts views Thread by TARUN | last post: by
reply views Thread by leo001 | last post: by

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.