473,544 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I determine the status of the default printer

How do I find out if the default printer is offline or online (or has a
paper jam)?
Nov 20 '05 #1
3 25235
Hello,

"Raymond Martin" <ra*****@bellso uth.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
PrinterWarmingU p = 5
' For more states see WMI docs.
End Enum

Private Function PrinterStatusTo String( _
ByVal ps As PrinterStatus _
) As String
Dim s As String
Select Case ps
Case PrinterStatus.P rinterIdle
s = "waiting (idle)"
Case PrinterStatus.P rinterPrinting
s = "printing"
Case PrinterStatus.P rinterWarmingUp
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.EventArg s _
) Handles MyBase.Load
Dim strPrintServer As String
strPrintServer = "localhost"
Dim WMIObject As String, PrinterSet As Object, Printer As Object
WMIObject = "winmgmts://" & strPrintServer
PrinterSet = GetObject(WMIOb ject).Instances Of("win32_Print er")
For Each Printer In PrinterSet
MsgBox( _
Printer.Name & ": " & _
PrinterStatusTo String(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
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.ac tivevb.de> wrote in message
news:#k******** *****@TK2MSFTNG P11.phx.gbl...
Hello,

"Raymond Martin" <ra*****@bellso uth.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
PrinterWarmingU p = 5
' For more states see WMI docs.
End Enum

Private Function PrinterStatusTo String( _
ByVal ps As PrinterStatus _
) As String
Dim s As String
Select Case ps
Case PrinterStatus.P rinterIdle
s = "waiting (idle)"
Case PrinterStatus.P rinterPrinting
s = "printing"
Case PrinterStatus.P rinterWarmingUp
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.EventArg s _
) Handles MyBase.Load
Dim strPrintServer As String
strPrintServer = "localhost"
Dim WMIObject As String, PrinterSet As Object, Printer As Object
WMIObject = "winmgmts://" & strPrintServer
PrinterSet = GetObject(WMIOb ject).Instances Of("win32_Print er")
For Each Printer In PrinterSet
MsgBox( _
Printer.Name & ": " & _
PrinterStatusTo String(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
Hello,

"Raymond Martin" <ra*****@bellso uth.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
12995
by: Pablo | last post by:
Friends, how can i get the name of the default printer??. I'm working with winforms. VB,C#, nevermind. Thanks a lot Pablo
0
2564
by: Esmee | last post by:
Hi there, I have created an Access 2002 db which contains several reports. Some reports need to be printed on a Laserjet and others on a Labelprinter. One of my clients wants to be able to print the same reports to 3 different laserjets and to 3 different labelprinters. (They work with the db on 3 different units each with their own...
2
2098
by: MLH | last post by:
I would like to allow users to set, as an application default, a specific printer to send reports to. I don't know how to bring up a list of valid print devices in A97, nor do I know how to reference any one of them that might be selected. For instance, if I click Start, Control Panel, Printers and Faxes on a PC running XP and I see the...
1
5436
by: i8mypnuts | last post by:
Could someone please help? I am using the 'defaultprt.zip' tool provided by Ken Getz to change the default printer via VBA code (code below). My problem is that once the default printer has been changed, Access 2003 still directs the report to the former default printer. Access 2003 picks up the new default printer setting only after I have...
1
2347
by: groulder | last post by:
hi all, i have a problem with a network database that's used by a lot of people. people are finding, they will start the database, and if the mouse is moved over the print icon, the tooltip appears to show which printer it will print to as normal. this printer however is a printer that the user doesn't even have installed.
3
2398
by: MLH | last post by:
Access 97 Q: Can I examine a report object property setting in VBA and tell whether the report is setup to print to a specific printer or to the windows default printer? You know, the setting you see in the little window that appears when you open report in design view, click File, Page Setup, the Page tab (middle one). There's a little...
13
9071
by: Mark Rae | last post by:
Hi, I have used the code below to return the default printer in 32-bit WinXP Pro, but now that I am running 64-bit Vista Business I'm getting an error: using System.Drawing.Printing; using (PrintDocument objPrintDocument = new PrintDocument()) { string strDefaultPrinter =
4
2400
by: David C. Barber | last post by:
my.computer.printers.defaultprinter doesn't exist in 2005, despite the plethora of examples still out on the web detailing its use. So how can I determine a person's default printer using ASP 2? Thanks!
3
4252
by: brianflannery | last post by:
Greetings all! My problem is this. I've installed a new printer on my computer. This is the "default printer" for access. Now, some of my reports, which were working fine with the old printer, are now showing up with an odd view (very enlarged) in preview. If I go to page setup, and choose specific printer to then look at the paper size...
0
7413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7597
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. ...
1
7358
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5894
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...
1
5286
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...
0
4902
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1831
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
1
980
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.