By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,890 Members | 1,269 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,890 IT Pros & Developers. It's quick & easy.

How can I determine the status of the default printer

P: n/a
How do I find out if the default printer is offline or online (or has a
paper jam)?
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hello,

"Raymond Martin" <ra*****@bellsouth.net> schrieb:
How do I find out if the default printer is offline or online (or has a
paper jam)?


\\\
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
Return 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
///

Documentation of WMI classes:

http://msdn.microsoft.com/library/de...mi_classes.asp

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 20 '05 #2

P: n/a
Thanks for this Herfried - it seems like a lot of work but I can follow the
example pretty well. Thanks for the link to the WMI documentation. One
thing - this example iterates thru all the available printers. How do I know
which one is the default printer?
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:#k*************@TK2MSFTNGP11.phx.gbl...
Hello,

"Raymond Martin" <ra*****@bellsouth.net> schrieb:
How do I find out if the default printer is offline or online (or has a
paper jam)?
\\\
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
Return 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
///

Documentation of WMI classes:

http://msdn.microsoft.com/library/de...us/wmisdk/wmi/
wmi_classes.asp
HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet

Nov 20 '05 #3

P: n/a
Hello,

"Raymond Martin" <ra*****@bellsouth.net> schrieb:
Thanks for this Herfried - it seems like a lot of work but I
can follow the example pretty well. Thanks for the link to
the WMI documentation. One thing - this example iterates
thru all the available printers. How do I know which one
is the default printer?


http://groups.google.de/groups?ie=UT...efault+printer

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.