Sudz
Sudz

Reputation: 4308

Check default printer is on or not

How can i figure out whether default printer is on or not using vb.net or C# (on .Net 2.0)

And what is the port number to which printer is attached.

I am using PrinterSettings Class, but there is no method in it to get those values.

Upvotes: 0

Views: 954

Answers (2)

Priscilla Jobin
Priscilla Jobin

Reputation: 607

You can get port number using this code.

private void cboPrinters_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
  PrintQueue printer = cboPrinters.SelectedItem as PrintQueue;
  string portname = printer.QueuePort.Name;
}

Upvotes: 1

Freelancer
Freelancer

Reputation: 9074

Use Following:

string strDefaultPrinter;
using(var printServer = new LocalPrintServer())
{
  strDefaultPrinter= printServer.DefaultPrintQueue.FullName);
}

In this way you can set default printer in one string and can compare with detected printer.

Upvotes: 0

Related Questions