I’ve got a desktop application with a listview filled with installed printers on my local computer. This is a simple printer managed, so I want to be able to right click on an item and then delete that particular printer. How can I do this?
Here is how I list the printers
Public Sub listInstalledPrinters()
Dim i As Integer
Dim pkInstalledPrinters As String
For i = 0 To printersettings.InstalledPrinters.Count - 1
pkInstalledPrinters = PrinterSettings.InstalledPrinters.Item(i)
listViewLocal.Items.Add(pkInstalledPrinters, nIndex)
Next
End Sub
But how can I delete one of them? Is there a built-in way of doing this?
If you query the printers via
System.Management.ManagementScope, you can easily delete them using theDeletemethod of theManagementObjectclass.