C#里如何获取打印机里打印档案名称,打印档案大小
C#里如何获取打印机里打印档案名称,打印档案大小
也就是要对打印机进行监控,做过的朋友说下,谢了
------解决方案--------------------using System;
using System.Management;
using System.Windows.Forms;
namespace WMISample
{
public class MyWMIQuery
{
public static void Main()
{
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher( "root\\CIMV2 ",
"SELECT * FROM Win32_PrintJob ");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine( "----------------------------------- ");
Console.WriteLine( "Win32_PrintJob instance ");
Console.WriteLine( "----------------------------------- ");
Console.WriteLine( "Document: {0} ", queryObj[ "Document "]);
}
}
catch (ManagementException e)
{
MessageBox.Show( "An error occurred while querying for WMI data: " + e.Message);
}
}
}
}