难题挑战打印高手(难!!!!) (100分)

  • 主题发起人 plane822
  • 开始时间
怎样才能知道打印机是否连机,而不是只安装了驱动呢
 
我说说,不一定很对。
1.页面用什么生成并不重要。无论你用什么生成都会掉进打印池。检测打印池几乎是不可能
的。看看页面的流程你会明白了:应用程序->EMF->GDI->Splooes.exe->
LocalSpl.dll/win32spl.dll->打印池->本地打印提供者->打印处理器->语言监视器->
端口监视器->端口。
2.打印机是否联机,是另外一条线。win98/me中是通过wm_aploolerstatus消息,但这种方
法在WinNT/2000下不灵。在WinNT/2000下,你可以建立一个打印机状态通知事件,在消息循
环中监视,或者专门开一个线程监视这个事件。打印机状态通知事件中有一个通知类型是
PRINTER_NOTIFY_FIELD_STATUS,其参数指向一个PRINTER_INFO_2结构,其中可以查到详细的
状态。在win98下你等候wm-sploolerstatus消息到达后,主动调用EnumPrinterDrivers函
数查询打印机状态即可。
3.你最好建立自己的打印机列表,并随时检查状态。在收到wm_devicechange通知后即时更
新这个列表。
 
本人水平可能较差一点,难以把各位的意见给附注与行动,
还请高手能详细说明,或者有代码,不胜感激
 
在WinNT/2000下,你可以建立一个打印机状态通知事件,在消息循
环中监视,或者专门开一个线程监视这个事件
这该怎么下手呢????
 
我也想知道
 
没用难道!~?
 
判定打印机是否缺纸
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)
 
我是通过多个网络打印服务器来打印的,上面的根本就不行,
并且本地的没有打印机也检测不到
 
怎么监控通知消息?可以给出原代码吗?
 
我也为这个问题在头痛!谁能解决,请给一份给我吗?
 
winxp下,有那些api,编译是不能通过,怎么解决
 
问题我自己一直没解决,如果那位知道还请不吝指教
 
为什么FindNextPrinterChangeNotification不能监控打印机状态的改变?如offline等。
 
同意shbjkl( ID:1878308 )的!
动态的设立默认的打印机
其实,用程序自动控制,实现后台打印才是最好的方法!!!!
//////////可参考例程
begin
ListBox1.Items := Printer.Printers;
ListBox1.ItemIndex := Printer.PrinterIndex;
end;

{
procedure TForm1.Button2Click(Sender: TObject);
Var
FHandle : THandle;
HPrt : THandle;
PrtInfo5: PPrinterInfo5;
FDevice: array[0..79] of char;
FDriver: array[0..79] of char;
FPort: array[0..79] of char;
begin

Printer.PrinterIndex := ListBox1.ItemIndex;
Printer.GetPrinter (FDevice, FDriver, FPort, FHandle);
if FHandle = 0 then
begin
{driver not loaded}
Printer.PrinterIndex := Printer.PrinterIndex;
{-forces Printer object to load driver}
end;
{ if... }
Printer.GetPrinter (FDevice, FDriver, FPort, FHandle);
OpenPrinter(FDevice, HPrt, nil);
if HPrt = 0 then
raise(Exception.Create('Couldn''t open printer'));
try
PrtInfo5 := GetPrinterInfo5(HPrt);
PrtInfo5.Attributes := PrtInfo5.Attributes + PRINTER_ATTRIBUTE_DEFAULT;
SetPrinter(HPrt,5,PrtInfo5,PRINTER_CONTROL_SET_STATUS);
FreeMem(PrtInfo5);
finally
ClosePrinter(HPrt);
end;

 
顶部