GetPrinter在Winme 下的打印机状态总是返回0呢?谁能用api的到打印机的状态,送 500分 (100分)

  • 主题发起人 plane822
  • 开始时间
P

plane822

Unregistered / Unconfirmed
GUEST, unregistred user!
Procedure Tpppp.Button5Click(Sender: TObject);
Var
ss: String;
prnhandle: Thandle;
info: Pointer;
n: DWORD;
s1, s2, s3: Array[0..1024] Of char;
hmem: DWORD;
begin
{ ss := copy(Printer.printers[StrToInt(edit1.Text)], 1,
pos(' on ', Printer.printers[StrToInt(edit1.Text)]) - 1);}
ss :='CF2';
openprinter(Pchar('Cf2'), prnhandle, Nil);
// PrinterProperties(handle,prnhandle);
// openprinter('AGFA-AccuSet 1000', prnhandle, Nil);
GetPrinter(prnhandle, 2, @info, 0, @n);
If (GetLastError() = 122) then
GetMem(info, n)
else
begin
N := GetLastError();
showmessage(inttostr(n));
exit;
end;
IF GetPrinter(prnhandle, 2, info, n, @n) then
ShowMessage(inttostr(PRINTER_INFO_2(info^).Status));
// ShowMessage(Form1.PrinterStatusText(PRINTER_INFO_2(info^).Status));
closeprinter(prnhandle);
end;
为什么我的打印机状态Status总是返回0?
 
Why????????????????????/
还有其他办法能得到打印机的状态吗???
 
为什么大家都不????????
 
我也正因为这个问题纳闷呢。
 
有谁不纳闷呢??请各位富翁多帮忙
 
在你的机器上能正常打印吗
 
打印都很正常
 
Delphi有个函数 SysErrorMessage,你把GetLastError得到值传进去,看看系统的提示是什么
 
To mywyn
操作已成功完成。可是还是返回0
 
我的是2k试了一下如果打印机暂停打印可以得到一个暂停打印的状态。其他情况为0
程序应该是正确的。
 
可是在没有连接打印机的时候也是返回0,我怎么才能判断打印机是
正常,缺纸,或者没连线?????
 
这个问题论坛里有很多解决方案,但没有可以解决问题的
搜索一下
因为没有打印机也没法试,呵呵
 
我的体会:
很可能是你的打印机驱动程序不对,你应该在win2000下吧,
千万不要用win2000自带的驱动程序,去下载支持win2000的
试试
 
正式因为搜遍了,还没找到能解决问题的答案
所以才不的不重新提以下,或者那位能告一声这个问题根本就行不通也成
 
PrinterMessageBox :显示打印作业出错信息
WaitForPrinterChange
EnumJobs:获取打印作业信息
 
呵呵差点忘了
function TestPrinterStatus(LPTPort: word): byte;
var
Status: byte;
CheckLPT: word;
begin

Status := 0;
// 扫描端口
if (LPTPort >= 1) and (LPTPort <= 3) then

begin

CheckLPT := LPTPort -1;
asm
mov dx, CheckLPT;
mov al, 0;
mov ah, 2;
int 17h;
mov &amp;Status, ah;
end;

end;

Result := Status;
end;

//返回的错误:自己转换就可以了
01h - Timeout
08h - I/O Error
10h - Printer selected
20h - Out of paper
40h - Printer acknowledgement
80h - Printer not busy (0 if busy)
 
非常感谢各位的热心帮助
我没连接打印机时,只是安装了驱动程序,楼上的也不能返回正确值
我现在的打印机端口也不是两三个,是安装了打印服务器
所以端口现在总也在10个左右,要在每个打印机出现问题时有提示
 
又是TeamB里面的,好像说的也是这样……
In article <38A25376.138F5575@technologist.com>, Patrick Sabourin
wrote:
> Is it possible to programmatically find out if the printer is on?
>
If you print using the Windows Print Spooler (i.e. via the Printer
object) youdo
n't need to worry about that, the spooler will take
care of it. There is no reliable way to detect the printer state
under all circumstances. Theoretically Winspool.GetPrinter should
return a printer state (in a TPrinterInfo2 record) but in practice
this rarely works for some reason...
Peter Below (TeamB) 100113.1101@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Sent using Virtual Access 5.00 -do
wnload your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe
 
我能提供的就这些了,你看着办。
 
what can Ido
? who help me!
 
顶部