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
"Brian" <Br***@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com...
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.
"Ollie Riches" wrote:
I recommend you use the Management (WMI) Extensions for Visual Studio
.NET
2003 Server Explorer
http://www.microsoft.com/downloads/d...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
"Brian" <Br***@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com... > 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.