VB.NET – How to get the model of any connected printer in VB .NET

As mentioned in the question, I need to use vb dotNet to find the printer model.

I have used EnumPrinters API and checked the driver name, but the same name The driver supports certain printers (i.e. the driver supports a range of printers), which prevents me from distinguishing them.

I need to output as

This may be related to vb.net/any other languages

I do not intend to write all the code for you, but Please check the DriverName property. Run the entire process in debug mode to see the other properties available to you. You need to add references 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)< br /> Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher(query)
Dim collection As ManagementObjectCollection = searcher.Get()

For Each printer As ManagementObj ect 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

As mentioned in the question, I need Use vb dotNet to find the printer model.

Currently, EnumPrinters API has been used and the driver name is checked, but the same named driver supports some printers (that is, the driver supports a series of printers), which makes I can't distinguish them.

I need to output as

This may be related to vb.net/any other languages

I don’t plan to write all the code for you, but please check the DriverName property. Run the whole process in debug mode to see the other properties available to you. You need to add a pair of System.Drawing and Reference to 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}'", printerNam e)
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< br /> Next
End Sub

End Module

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3399 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.