Torna al Thread

Dim path As New System.Management.ManagementPath("root\cimv2") Dim options As New System.Management.ConnectionOptions path.Server = "." Dim scope As New System.Management.ManagementScope(path, options) Dim query As New System.Management.ObjectQuery("SELECT Name, Document, JobStatus, Owner, TotalPages, Size, TimeSubmitted FROM Win32_PrintJob") Dim search As New System.Management.ManagementObjectSearcher(scope, query) Dim objectCollection As System.Management.ManagementObjectCollection objectCollection = search.Get() Dim printerName, document, owner As String Dim pages, size As System.UInt32 Dim timeSubmitted As DateTime For Each prntJob As System.Management.ManagementObject In objectCollection printerName = prntJob("Name").ToString().Split(","c)(0) document = prntJob("Document").ToString() owner = prntJob("Owner").ToString() pages = System.Convert.ToUInt32(prntJob("TotalPages")) size = System.Convert.ToUInt32(prntJob("Size")) timeSubmitted = System.Management.ManagementDateTimeConverter.ToDateTime(prntJob("TimeSubmitted").ToString()) Dim litem As ListViewItem litem = ListView1.Items.Add("") litem.SubItems.Add(printerName) litem.SubItems.Add(timeSubmitted.ToString("G")) litem.SubItems.Add(document) 'litem.SubItems.Add(owner) litem.SubItems.Add(IIf(pages = 0, "N/D", pages.ToString("#,##0")).ToString()) litem.SubItems.Add(System.Convert.ToInt32(size / 1024).ToString("#,##0") & " KB") Next Catch MessageBox.Show(Err.Description) End Try
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5