How to get the model number of any connected printer in vb.net

As the question says, I need to find the printer model number using vb dotNet.

Currently, the EnumPrinters API is used and the driver name is checked, however, some printers are supported by the same driver (i.e. the driver supports a series of printers), which does not allow me to distinguish between them.

I need the output of <manufacturer> <model> <codes> .

This is possible using vb.net/any another language

+4
source share
1 answer

Not going to quote all of this for you, but check the DriverName property. Run all this in debug mode to see another property available to you. You will need to add links to System.Drawing and System.Management.

 Imports System.Drawing.Printing Imports System.Management Module Module1 Sub Main() Dim printers = PrinterSettings.InstalledPrinters For Each printerName As String In printers Dim query As String = String.Format("SELECT * from Win32_Printer WHERE Name LIKE '%{0}'", printerName) Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher(query) Dim collection As ManagementObjectCollection = searcher.Get() For Each printer As ManagementObject In collection For Each propData As PropertyData In printer.Properties Debug.WriteLine(String.Format("{0}: {1}", propData.Name, propData.Value)) Next Next Next End Sub End Module 
+1
source

Source: https://habr.com/ru/post/1413455/


All Articles