2

What I am trying to do:

I am creating a database of all printer installed on a computer.

Using PrinterSetting.PrinterName and PrinterSettings.InstalledPrinters I am getting PrinterName.

I have also tried winapi Win32_Printer but this and my above code has a problem.

Problem

The problem is that a single printer can be installed by different names like HP LasetJet 1020, HP LasetJet 1020 (Copy 1), HP LasetJet 1020 (Copy 2), and so on. A printer name is user-defined and can be any. Even may be one printer can be installed by 2 such different names that they have no similarity between their names.

That's why i think Printer Model Name should be unique even if one printer is installed by different names.

Question:

How to extract that Printer Mode Name? or may be any other property in Win_32 that is unique, uneditable by user and can be used to identify printers.

OR

May be registry can be helpful for this. If this model information is in registry(Most probably it will be) where can it be found?

Nikhil Agrawal
  • 47,018
  • 22
  • 121
  • 208
  • 2
    And if the user has two identical printers actually attached? Generally, if the user has set up the printer under two different names, it's because they want/need to treat them as logically different devices. – Damien_The_Unbeliever Jun 19 '12 at 13:11
  • `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers`. Under the listed Printers look into this subkey - `PrinterDriverData`. [I am not sure though if this will resolve your issue.] AFAIK, Printer serial numbers / model nos. are not exposed by vendors else `WIN32_Printers` would have listed that as a property. Alternatively, you may try researching this WIN32 API `SetupDiEnumDeviceInterfaces` – Angshuman Agarwal Jun 19 '12 at 13:17
  • @Damien_The_Unbeliever: No problem. That is a scenario is possible. But first to even know that there are two same printers i need to know their models. – Nikhil Agrawal Jun 19 '12 at 13:19

2 Answers2

1

The combination of printer driver name and port name form the only unique identifier for a specific printer. If the driver and port names match between two printers, then those printers both represent the same physical (or virtual) piece of hardware. No other properties reliably identify them.

Carey Gregory
  • 6,836
  • 2
  • 26
  • 47
0

I'd tackle this with WMI, it looks like there might be a little more info that way.

There's a decent walkthrough on CodeProject, but I can't say I've dealt with this specifically, just thought I'd point you in that direction.

http://www.codeproject.com/Articles/80680/Managing-Printers-Programatically-using-C-and-WMI

Breland
  • 183
  • 1
  • 11