Buongiorno,
come da titolo vorrei leggere il numero totale di stampe su una specifica stampante.
Ora riesco tramite il codice qui sotto e la procedura Select * from Win32_printer a leggere i vari dati, mentre pensavo che con la seconda di ricevere i dati che mi servivano SELECT * FROM Win32_PrintJob , ma non inserisce nulla.
codice:
Dim NomeS As String = "WF-3720" Dim Query As String = String.Format("Select * from Win32_printer where name like '%{0}'", NomeS)
Dim Searcher As ManagementObjectSearcher = New ManagementObjectSearcher(Query)
Dim Coll As ManagementObjectCollection = Searcher.Get()
Dim Printer As New ManagementObject
Try
For Each mo As ManagementObject In Coll
For Each prop As PropertyData In mo.Properties
ListBox1.Items.Add(String.Format("{0}: {1}", prop.Name, prop.Value))
' LStato.Text &= "STAMPANTE : " & (String.Format("{0}: {1}", prop.Name, prop.Value))
Next
Next
Dim NomeS2 As String = "WF-3720"
Dim searchQuery As String = String.Format("SELECT * FROM Win32_PrintJob where name like '%{0}'", NomeS2)
Dim searchPrintJobs As ManagementObjectSearcher = New ManagementObjectSearcher(searchQuery)
Dim prntJobCollection As ManagementObjectCollection = searchPrintJobs.[Get]()
For Each prntJob As ManagementObject In prntJobCollection
Dim documentName As String = prntJob.Properties("Document").Value.ToString()
Dim jobSatus As UInt32 = CType(prntJob.Properties("StatusMask").Value, UInt32)
Dim pagesPrinted As UInt32 = CType(prntJob.Properties("PagesPrinted").Value, UInt32)
Dim totalPages As UInt32 = CType(prntJob.Properties("TotalPages").Value, UInt32)
ListBox2.Items.Add(totalPages)
Next
dove sbaglio? Ho provato anche altri codici e soluzioni, ma il numero di stampe non lo rileva.
Grazie