422,727 Members | 2,160 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,727 IT Pros & Developers. It's quick & easy.

Check Printer Status??? How??

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
* "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.