PC Review


Reply
Thread Tools Rate Thread

How can I determine the status of the default printer

 
 
Raymond Martin
Guest
Posts: n/a
 
      31st Aug 2003
How do I find out if the default printer is offline or online (or has a
paper jam)?


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      31st Aug 2003
Hello,

"Raymond Martin" <(E-Mail Removed)> 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


 
Reply With Quote
 
Raymond Martin
Guest
Posts: n/a
 
      1st Sep 2003
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]" <(E-Mail Removed)> wrote in message
news:#kSXDW$(E-Mail Removed)...
> Hello,
>
> "Raymond Martin" <(E-Mail Removed)> 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
>
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      1st Sep 2003
Hello,

"Raymond Martin" <(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vista keeps stealing default status from default printer computer =?Utf-8?B?ZS50Lg==?= Windows Vista Networking 0 22nd Aug 2007 03:40 AM
How to determine Fax Job Status Tore Bostrup Microsoft Windows 2000 Fax 5 27th Jun 2005 11:09 AM
determine default printer dans Microsoft Windows 2000 Printing 1 1st Jun 2004 04:06 PM
Epson C84 Reassumes Default Printer Status Without Asking mclazyj Windows XP Print / Fax 1 3rd May 2004 08:00 AM
How to determine default printer AND then set as LPT1 Ray Microsoft Windows 2000 0 22nd Dec 2003 05:37 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:55 PM.