mike A

mike A

  • NA
  • 19
  • 0

webbrowser control to install printers, how to detect 'click' or printer install

Sep 10 2009 1:30 PM

I have a web browser which views a print server.  The user can click on any printer and it will install on their machine.  Below, I have a listview control with the installed printers.  The user can use this to selct and remove installed printers.  I'm trying to have the listview update each time the user clicks on and installs a printer from the browser control.  None of the options on webbrowser handles events seems to accomplish this. please help below is my code (I would like to trigger the 'ListLocalPrinters()' function when a new printer is installed from the web browser):
 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
brwsList.Navigate(
\\print-server) ' brwsList is used as File Explorer.
ListLocalPrinters()
End Sub
 
Private Sub ListLocalPrinters()
Try
Dim searcher As New ManagementObjectSearcher("root\CIMV2", _
"SELECT * FROM Win32_Printer Where Local = FALSE")
lstPrtrToDelete.Items.Clear()
For Each queryObj As ManagementObject In searcher.Get()
lstPrtrToDelete.Items.Add(queryObj(
"DeviceID"))
Next
lstPrtrToDelete.View = View.List
Catch err As ManagementException
MessageBox.Show(
"An error occurred while querying for WMI data: " & err.Message)
End Try
End Sub

Answers (1)