我需要取得打印机的状态,查了一些资料底下是一些代码
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包也不管用
解决方案 »
- SetWindowsHookEx 失败 返回0x0005 拒绝存取——已经第3贴了
- 应该如何禁止程序在进程中强制关闭?
- 可不可以开发一个开发的聊天工具,用户名@网站名,来互通聊天?
- 请问,计算机的串口可以正常接波特率不标准的232信号吗?
- 拜托大虾门告诉我,如何在对话框中改变输入法
- 不是标准的波特率,怎么用vc实现阿 ???急用啊,请高人指点!!!
- 编译出现cannot open file "mfc42ud.lib"的错误!
- 一个简单的问题
- 请问我的代码错在什么地方?
- 使用ADO的Recordset如何得到第一个字段的值?函数是什么?谢谢
- 这种情况如何解决啊??
- 谁能告诉我VSS的怎么从vc里Check out,谢谢各位。
改为
pi2 = new BYTE[dwNeeded];
最后delete []pi2;