Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2007

Tip: Looking for answers? Try searching our database.

Win32_Printer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Harry Simpson - 30 Jul 2004 22:59 GMT
I'm trying to grab printer status for a printer with WMI

I got a mo("PrinterState").tostring of "128" for a paused HP printer. What
is "128" equate to?  It did give a mo("PrinterStatus").tostring of 1 =
"paused" which was correct but it took a while to display the correct state.

When I un-paused the printer, I got a mo("PrinterState").tostring of "0".
What is "0" equate to?  It got a mo("PrinterStatus").tostring of 0.  Is "0"
mean ok, ready?

Anyone had experience in correctly grabbing info from WMI?

I'm getting info but not consistent info and i don't know how to translate
the codes since they don't match up with the ones in the WMI SDK.

Any clues as how to effectively use
Management.ManagementObjectSearcher("Select * from Win32_Printer")

to get accurate info on networked printers within a domain?

TIA

Harry
Lebrun Thomas - 31 Jul 2004 10:43 GMT
> I got a mo("PrinterState").tostring of "128" for a paused HP printer. What
> is "128" equate to?

Maybe it's the memory of your printer ?

What is "0" equate to?  It got a mo("PrinterStatus").tostring of 0.  Is "0"
> mean ok, ready?

I believe.

Bye.

--
LEBRUN Thomas
http://morpheus.developpez.com

> I'm trying to grab printer status for a printer with WMI
>
[quoted text clipped - 19 lines]
>
> Harry
Harry Simpson - 02 Aug 2004 15:25 GMT
Has anyone actually used this and could help me out.  I've got plenty of
guesses about it -  i need to find out what these represent and if WIM
actually works or not.

Thanks

Harry

> > I got a mo("PrinterState").tostring of "128" for a paused HP printer. What
> > is "128" equate to?
[quoted text clipped - 37 lines]
> >
> > Harry
Jason Newell - 03 Aug 2004 01:29 GMT
Harry,
   The following code works on my machine.  I used the following url as a
guide.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win3
2_printer.asp


Signature

Jason Newell, MCAD
Software Engineer

using System;
using System.Management;

namespace PrinterTest
{
class Class1
{
 [STAThread]
 static void Main(string[] args)
 {
  ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select
* from Win32_Printer");

  foreach (ManagementObject printer in searcher.Get())
  {
   string message = (string)printer["Name"] + ": Printer Status = ";

   /* PrinterState is obsolete! */
   switch ((UInt16)printer["PrinterStatus"])
   {
    case 1:
     message += " Other";
     break;
    case 2:
     message += " Unknown";
     break;
    case 3:
     message += " Idle";
     break;
    case 4:
     message += " Printing";
     break;
    case 5:
     message += " Warmup";
     break;
    case 6:
     message += " Stopped printing";
     break;
    case 7:
     message += " Offline";
     break;
    default:
     message += " ERROR - Constant not defined";
     break;
   }
   Console.WriteLine(message);
  }
  Console.In.Read();
 }
}
}

> Has anyone actually used this and could help me out.  I've got plenty of
> guesses about it -  i need to find out what these represent and if WIM
[quoted text clipped - 50 lines]
> > >
> > > Harry
Jason Newell - 03 Aug 2004 01:42 GMT
BTW,
   If that's not good enough, the same thing can be easily accomplished
using OpenPrinter(), GetPrinter(), ClosePrinter() Win32 methods.  If you
need an example, let me know what language you want it in and I can send you
an example.

Signature

Jason Newell, MCAD
Software Engineer

> Harry,
>     The following code works on my machine.  I used the following url as a
> guide.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win3
2_printer.asp


> > Has anyone actually used this and could help me out.  I've got plenty of
> > guesses about it -  i need to find out what these represent and if WIM
[quoted text clipped - 51 lines]
> > > >
> > > > Harry
Harry Simpson - 03 Aug 2004 16:50 GMT
Jason,

I used your code in a C# project and, yes, it "works" just like my code
"works".  Where it doesn't work is if you pause the printer, turn of the
printer, throw the printer out the window, - the PrinterStatus remains 3 or
"Idle" instead of showing the true state of the printer.

We were using the API calls to the winspool.drv and that code did seem to
work accurately, but it's unmanged code within managed code.  Ever so often,
the unmanged code would crash and bring down the whole app.

Really appreciate your time on this Jason!

Harry
MCSD

PS. VB.NET is code of choice.
> BTW,
>     If that's not good enough, the same thing can be easily accomplished
[quoted text clipped - 5 lines]
> >     The following code works on my machine.  I used the following url as a
> > guide.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win3
2_printer.asp


> ManagementObjectSearcher("Select
> > * from Win32_Printer");
[quoted text clipped - 98 lines]
> > > > >
> > > > > Harry
Fernando Hunth - 26 Aug 2004 20:14 GMT
Harry :

Have you solved it ?
rsk7485 - 30 Jul 2007 13:20 GMT
Hi,
I am having same problem with printer status.
can i get the detailed code for retreiving printer status problem??
I am being working in that sinve a week and i am not getting the correct
result.
I will be very thankful for you...
Please...
Rahul Kadu

>Jason,
>
[quoted text clipped - 26 lines]
>> > > > >
>> > > > > Harry

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.