Get Installed Printer on Netwrok

Public Sub NetworkInstalledPrinter(ByVal strComputer As String, ByVal strUserName As String, ByVal strPwd As String)

        Try
            Dim Query As Management.ObjectQuery = New System.Management.ObjectQuery("SELECT * FROM Win32_Printer")
            Dim moSearcher As Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher(Query)
            Dim moc As Management.ManagementObjectCollection = moSearcher.Get()

            For Each mo As Management.ManagementObject In moc

                Dim Pdc As Management.PropertyDataCollection = mo.Properties

                For Each pd As Management.PropertyData In Pdc
                    Try
                        If (CType(mo("Network"), Boolean)) Then
                            Dim strName As String
                            strName = CType(mo(pd.Name), String)

                            If (strName.StartsWith("\\")) Then
                                MessageBox.Show(strName)
                            End If

                        End If
                    Catch ex As Exception
                        Continue For
                    End Try

                Next
            Next

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
        
End Sub

Related Posts by Categories



Stumble This Fav This With Technorati Add To Del.icio.us Digg This Add To Reddit Add To Facebook Add To Yahoo

0 comments:

Post a Comment