我需要取得打印机的状态,查了一些资料底下是一些代码
pi2 = (PRINTER_INFO_2 *)LocalAlloc (LPTR, dwNeeded);
/* Now actually get the information, and create an HDC if successful. */
if (EnumPrinters (PRINTER_ENUM_DEFAULT | PRINTER_ENUM_LOCAL,
NULL, 2,
(LPBYTE) pi2, dwNeeded,
&dwNeeded, &dwReturned)) 但取pi2的status成员,始终为0,其他的成员取得是正常的又用微软的Knowledge Base的文章:“Q160129 OWTO: Get the Status of a Printer and a Print Job”
例子,
/* Get the printer information. */
if (!GetPrinter(hPrinter,
2,
(LPSTR)pPrinterInfo,
cByteNeeded,
&cByteUsed))
if (dwPrinterStatus &
(PRINTER_STATUS_ERROR |
PRINTER_STATUS_PAPER_JAM |
PRINTER_STATUS_PAPER_OUT |
PRINTER_STATUS_PAPER_PROBLEM |
PRINTER_STATUS_OUTPUT_BIN_FULL |
PRINTER_STATUS_NOT_AVAILABLE |
PRINTER_STATUS_NO_TONER |
PRINTER_STATUS_OUT_OF_MEMORY |
PRINTER_STATUS_OFFLINE |
PRINTER_STATUS_DOOR_OPEN))
{
return TRUE;
}
取得的状态也是0苦,大家知道是什么原因吗
另外,我的winspool.h中也没有getdefaultprinter声明,安装了vs6sp5包也不管用
pi2 = (PRINTER_INFO_2 *)LocalAlloc (LPTR, dwNeeded);
/* Now actually get the information, and create an HDC if successful. */
if (EnumPrinters (PRINTER_ENUM_DEFAULT | PRINTER_ENUM_LOCAL,
NULL, 2,
(LPBYTE) pi2, dwNeeded,
&dwNeeded, &dwReturned)) 但取pi2的status成员,始终为0,其他的成员取得是正常的又用微软的Knowledge Base的文章:“Q160129 OWTO: Get the Status of a Printer and a Print Job”
例子,
/* Get the printer information. */
if (!GetPrinter(hPrinter,
2,
(LPSTR)pPrinterInfo,
cByteNeeded,
&cByteUsed))
if (dwPrinterStatus &
(PRINTER_STATUS_ERROR |
PRINTER_STATUS_PAPER_JAM |
PRINTER_STATUS_PAPER_OUT |
PRINTER_STATUS_PAPER_PROBLEM |
PRINTER_STATUS_OUTPUT_BIN_FULL |
PRINTER_STATUS_NOT_AVAILABLE |
PRINTER_STATUS_NO_TONER |
PRINTER_STATUS_OUT_OF_MEMORY |
PRINTER_STATUS_OFFLINE |
PRINTER_STATUS_DOOR_OPEN))
{
return TRUE;
}
取得的状态也是0苦,大家知道是什么原因吗
另外,我的winspool.h中也没有getdefaultprinter声明,安装了vs6sp5包也不管用
改为
pi2 = new BYTE[dwNeeded];
最后delete []pi2;