Ermittelt die installierten Drucker auf einem lokalen oder remote PC
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyPrinter As New ArrayList
MyPrinter = GetPrinter("testpc")
For i = LBound(MyPrinter.ToArray) To UBound(MyPrinter.ToArray)
MsgBox(MyPrinter(i))
Next
End Sub
Private Function GetPrinter(ByVal Computer As String) As ArrayList
Dim objWMIService As Object
Dim objItems As Object
Dim objItem As Object
Dim AllPrinters As New ArrayList
objWMIService = GetObject("winmgmts:\\" & Computer & "\root\CIMV2")
objItems = objWMIService.ExecQuery("SELECT * FROM Win32_Printer")
For Each objItem In objItems
AllPrinters.Add(objItem.Caption)
Next
objWMIService = Nothing
objItems = Nothing
objItem = Nothing
Return AllPrinters
End Function
Kommentare zum Snippet