最新消息:

VC监控打印机

C/C++ admin 3519浏览 0评论

char temp[50];
HANDLE hPrinter = NULL;
DWORD dwNeeded = 0;
DWORD dwReturned = 0;
JOB_INFO_1 *pJobInfo = NULL;
int n = 0;
int ret = OpenPrinter(“\\192.168.10.13\Canon MX310 series Printer”, &hPrinter, NULL);
if(ret == 0)
{
p->MessageBox(“打开打印机失败!”);
return 0;
}

while(p->IsListening)
{
EnumJobs(hPrinter,0,0xFFFFFFFF,1,NULL,0,&dwNeeded,&dwReturned);
if((pJobInfo = (JOB_INFO_1*)malloc(dwNeeded)) == NULL)
{
p->MessageBox(“分配空间失败!”);
ClosePrinter(hPrinter);
return 0;
}
if(!EnumJobs(hPrinter,0,0xFFFFFFFF,1,(LPBYTE)pJobInfo,dwNeeded,&dwNeeded,&dwReturned))
{
p->MessageBox(“枚举失败!”);
ClosePrinter(hPrinter);
free(pJobInfo);
return 0;
}

if(p->id != pJobInfo->JobId)
{
n = p->m_list.GetItemCount();
p->m_list.InsertItem(n, pJobInfo->pDocument);
p->m_list.SetItemText(n, 1, pJobInfo->pDatatype);
p->m_list.SetItemText(n, 2, pJobInfo->pMachineName);
p->m_list.SetItemText(n, 3, pJobInfo->pUserName);
p->m_list.SetItemText(n, 4, pJobInfo->pPrinterName);
memset(temp, 0, sizeof(temp));
itoa(pJobInfo->JobId, temp, 10);
p->m_list.SetItemText(n, 5, temp);
p->id = pJobInfo->JobId;
}
free(pJobInfo);
Sleep(1000);
}

转载请注明:爱开源 » VC监控打印机

您必须 登录 才能发表评论!