windows,打印机无打印任务,仍不断打印

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/xiaobai19841984/article/details/47746653

   前几天碰到一个怪异事件,公司有个网络打印机一直打乱码,拔了网线就不打,一插起又打,一台一台看了所有的PC都没找到有打印任务,最后通过网络抓包,发现是其中一台PC发过来的,又在这个PC上看,还是没有打印任务,停止打印服务,重启,都不能解决。

   最后还是度娘解决所有问题:

1 停止打印服务print spooler

2 在运行输入spool,在弹出的文件夹中打开PRINTERS文件夹,删除里面所有文件(含隐藏文件)

3 重新启动打印服务print spooler

搞定,打完收工!


展开阅读全文

获取打印机任务打印页数错误问题

03-11

我根据MSDN上的例子写了一个获取打印机队列任务的程序,取任务的名称和打印页数。在本机安装虚拟打印机测试的结果都正确,为什么换成网络打印机进行测试,获得到的打印页数总是不对.这是为什么呀?rn[code=C/C++]rnBOOL CPrinter::GetJobs(HANDLE hPrinter, JOB_INFO_2 **ppJobInfo, int *pcJobs,DWORD *pStatus) rnrn DWORD cByteNeeded,nReturned,cByteUsed;rn JOB_INFO_2 *pJobStorage = NULL;rn PRINTER_INFO_2 *pPrinterInfo = NULL;rn rn if (!GetPrinter(hPrinter, 2, NULL, 0, &cByteNeeded))rn rn if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)rn return FALSE;rn rn rn pPrinterInfo = (PRINTER_INFO_2 *)malloc(cByteNeeded);rn if (!(pPrinterInfo))rn return FALSE;rn rn if (!GetPrinter(hPrinter,2,(unsigned char*)pPrinterInfo,cByteNeeded,&cByteUsed))rn rn free(pPrinterInfo);rn pPrinterInfo = NULL;rn return FALSE;rn rn rn if (!EnumJobs(hPrinter,0,pPrinterInfo->cJobs,2,NULL,0,(LPDWORD)&cByteNeeded,(LPDWORD)&nReturned))rn rn if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)rn rn free(pPrinterInfo);rn pPrinterInfo = NULL;rn return FALSE;rn rn rn pJobStorage = (JOB_INFO_2 *)malloc(cByteNeeded);rn if (!pJobStorage)rn rn free(pPrinterInfo);rn pPrinterInfo = NULL;rn return FALSE;rn rn ZeroMemory(pJobStorage, cByteNeeded);rn rn if (!EnumJobs(hPrinter,0,pPrinterInfo->cJobs,2,(LPBYTE)pJobStorage,cByteNeeded,(LPDWORD)&cByteUsed,(LPDWORD)&nReturned))rn rn free(pPrinterInfo);rn free(pJobStorage);rn pJobStorage = NULL;rn pPrinterInfo = NULL;rn return FALSE;rn rn rn *pcJobs = nReturned;rn *pStatus = pPrinterInfo->Status;rn *ppJobInfo = pJobStorage;rn free(pPrinterInfo);rnrn return TRUE;rnrnBOOL IsPrinterError(HANDLE hPrinter)rnrn rn JOB_INFO_2 *pJobs;rn int cJobs,i;rn DWORD dwPrinterStatus;rn rn if (!GetJobs(hPrinter, &pJobs, &cJobs, &dwPrinterStatus))rn return FALSE;rn rn for (i=0; i < cJobs; i++)rn rn DWORD dwPage=0;rn TCHAR buf[100];rn //if((pJobs[i].Status & JOB_STATUS_PRINTING || pJobs[i].Status & JOB_STATUS_SPOOLING))rn rnrn dwPage=pJobs[i].TotalPages;rn rn wsprintf(buf," 打印任务状态:%X,页数:%d",pJobs[i].Status,dwPage );rn WriteLog(buf);rn rn rnrn free( pJobs );rn return FALSE;rn rnrnrn//调用rnHANDLE handle;rnwhile(true)rnrn.......rnOpenPrinter("网络打印机名",&handle,NULL);rnIsPrinterError(handle); rnCloseHandle(handle);rn.......rnrnrnrn[/code] 论坛

没有更多推荐了,返回首页