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 / .NET Framework / General / September 2005

Tip: Looking for answers? Try searching our database.

Retrieving Printer informaiton

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian - 22 Sep 2005 14:31 GMT
Does anyone know how I can write a program to retrieve information about
printers.  Not the print queues but the physical hardware printer.  I want to
retrieve info such as pages printed.  If anyone has a sample program or can
point me in the right direction that would be great.
Ollie Riches - 22 Sep 2005 14:36 GMT
I recommend you use the Management (WMI) Extensions for Visual Studio .NET
2003 Server Explorer

http://www.microsoft.com/downloads/details.aspx?familyid=62D91A63-1253-4EA6-8599
-68FB3EF77DE1&displaylang=en


After install it you will be able to drag & drop the printer class into your
project and easily get printer hardware information.

HTH

Ollie Riches

> Does anyone know how I can write a program to retrieve information about
> printers.  Not the print queues but the physical hardware printer.  I want
> to
> retrieve info such as pages printed.  If anyone has a sample program or
> can
> point me in the right direction that would be great.
Brian - 22 Sep 2005 20:11 GMT
thanks for the info.  I downloaded and installed the WMI extensions.  Sorry
for sounding stupid but how do I use these extensions.  Where do I get the
printer class so I can drag and drop it into my project.

> I recommend you use the Management (WMI) Extensions for Visual Studio .NET
> 2003 Server Explorer
[quoted text clipped - 14 lines]
> > can
> > point me in the right direction that would be great.
Ollie Riches - 23 Sep 2005 09:21 GMT
If you open and create a .Net project (I recommend trying this with a
console application), then go to 'View' and select 'Server Explorer' from
the menu you should get the 'Server Explorer' appearing inside visual studio
(on the left usually),.

Expand the drop down list for 'Servers' and you should see a list of 7 child
nodes, these will include 'Management Classes' & 'Management Events'.

If you expand the 'Management Classes' you should see alot of nodes relating
to the machine hardware.

If you right click on the 'Printers' node and select 'Generate Managed
Class' it will generate a managed class in your project usually called
'Win32_Printer.cs' and from this class you will be able to get access to
printer information.

For example to get all the printer names on the network

using System;
using ConsoleApplication1.ROOT.CIMV2;
namespace ConsoleApplication1
{
   class Class1
   {
       [STAThread]
       static void Main(string[] args)
       {
           Printer.PrinterCollection printers = Printer.GetInstances();
           foreach(Printer printer in printers)
           {
               Console.WriteLine(printer.Name);
           }
           Console.ReadLine();
       }
   }
}

HTH

Ollie Riches

> thanks for the info.  I downloaded and installed the WMI extensions.
> Sorry
[quoted text clipped - 23 lines]
>> > can
>> > point me in the right direction that would be great.

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



©2009 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.