Use ManagementObjectSearcher to query Win32_PrintJob
using System;
using System.Management;
public class MainClass {
public static void Main() {
string query = "SELECT * FROM Win32_PrintJob";
using (ManagementObjectSearcher jobQuery = new ManagementObjectSearcher(query)) {
using (ManagementObjectCollection jobs = jobQuery.Get()) {
foreach (ManagementObject job in jobs) {
Console.WriteLine(job["JobID"]);
}
}
}
}
}
Related examples in the same category