AjithJoseph
Я решил эту проблему с помощью WMI. пример функции находится здесь:
public void PausePrintJob()
{
string searchQuery = "SELECT * FROM Win32_PrintJob";
ManagementObjectSearcher searchPrintJobs = new ManagementObjectSearcher(searchQuery);
ManagementObjectCollection prntJobCollection = searchPrintJobs.Get();
foreach (ManagementObject prntJob in prntJobCollection)
{
string Document = prntJob.Properties["Document"].Value.ToString();
string JobId = prntJob.Properties["JobId"].Value.ToString();
string name = prntJob.Properties["Name"].Value.ToString();
string PagePrinted = prntJob.Properties["PagesPrinted"].Value.ToString();
string Status = prntJob.Properties["Status"].Value.ToString();
string Totalpages = prntJob.Properties["TotalPages"].Value.ToString();
string[] row = new string[] {Document,JobId,name,PagePrinted,Status,Totalpages};
bool present = false;
int i=0;
foreach (DataGridViewRow item in dataGridView1.Rows)
{
if (Convert.ToString(item.Cells["JobId"].Value) == JobId)
{
present = true;
break;
}
++i;
}
if (present)
{
dataGridView1.Rows.RemoveAt(i);
}
dataGridView1.Rows.Add(row);
}
}