![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
Есть принтер HP P3015 (HP 3010). При печати иногда происходит замятие бумаги. Как отслеживать замятие бумаги программно? Пробовал отслеживать очередь печати (и если она не двигается, то считать, что это ошибка или замятие). НО! При замятии в очередь ничего не добавляется - под значком принтера написано 0 заданий в очереди. Если отправлять дальше файлы на печать, то там по прежнему красуется 0... Но, если устранить замятие, то принтер начинает печатать все файлы, которые были отправлены на печать. Наверное он хранит это все в своей встроенной памяти. Пробовал все, что нашел на поверхности в интернете... Так и не смог решить эту задачу.
Помогите пожалуйста из программы определить замятие бумаги конкретно для принтера HP P3015 (он же HP 3010 - драйверы одни). Или как определить, что у принтера ЛЮБАЯ ошибка. Последний раз редактировалось kiman.ru, 04.05.2011 в 15:45. |
|
#2
|
|||
|
|||
|
Мужики, помогите пожалуйста
![]() |
|
#3
|
|||
|
|||
|
Есть идеи как это делается?
|
|
#4
|
||||
|
||||
|
проверять Status в JOB_INFO_х на JOB_STATUS_ERROR, JOB_STATUS_PAPEROUT
|
|
#5
|
|||
|
|||
|
Цитата:
Не работает — программа не получает эти данные от принтера. Что делать? |
|
#6
|
||||
|
||||
|
Цитата:
|
|
#7
|
|||
|
|||
|
Код:
procedure TForm1.Button1Click(Sender: TObject);
var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port : array[0..255] of char;
hPrinter: THandle;
hDeviceMode: THandle;
pcbNeed,pcReturned: DWORD;
Buffer: Pointer;
begin
Printer.GetPrinter(Device, Driver, Port, hDeviceMode);
if not OpenPrinter(@Device, hPrinter, nil) then Exit;
GetPrinter(hPrinter, 2, nil,0,@pcbNeed);
GetMem(Buffer, pcbNeed);
if GetPrinter(hPrinter, 2, Buffer, pcbNeed, @pcbNeed) then
begin
if TPrinterInfo2A(Buffer^).pServerName <> nil then ListBox1.items.add('pServerName='+TPrinterInfo2A(Buffer^).pServerName);
if TPrinterInfo2A(Buffer^).pPrinterName <> nil then ListBox1.items.add('pPrinterName='+TPrinterInfo2A(Buffer^).pPrinterName);
if TPrinterInfo2A(Buffer^).pShareName <> nil then
ListBox1.items.add('pShareName='+TPrinterInfo2A(Buffer^).pShareName);
if TPrinterInfo2A(Buffer^).pComment <> nil then
ListBox1.items.add('pComment='+TPrinterInfo2A(Buffer^).pComment);
if TPrinterInfo2A(Buffer^).pLocation <> nil then
ListBox1.items.add('pLocation='+TPrinterInfo2A(Buffer^).pLocation);
if TPrinterInfo2A(Buffer^).pPortName <> nil then
ListBox1.items.add('pPortName='+TPrinterInfo2A(Buffer^).pPortName);
if TPrinterInfo2A(Buffer^).pDriverName <> nil then
ListBox1.items.add('pDriverName='+TPrinterInfo2A(Buffer^).pDriverName);
if TPrinterInfo2A(Buffer^).pSepFile <> nil then
ListBox1.items.add('pSepFile='+TPrinterInfo2A(Buffer^).pSepFile);
if TPrinterInfo2A(Buffer^).pPrintProcessor <> nil then ListBox1.items.add('pPrintProcessor='+TPrinterInfo2A(Buffer^).pPrintProcessor);
if TPrinterInfo2A(Buffer^).pDatatype <> nil then
ListBox1.items.add('pDatatype='+TPrinterInfo2A(Buffer^).pDatatype);
if TPrinterInfo2A(Buffer^).pParameters <> nil then
ListBox1.items.add('pParameters='+TPrinterInfo2A(Buffer^).pParameters);
ListBox1.items.add('Attributes='+inttostr(TPrinterInfo2A(Buffer^).Attributes));
if TPrinterInfo2A(Buffer^).Attributes and PRINTER_ATTRIBUTE_QUEUED = PRINTER_ATTRIBUTE_QUEUED then
ListBox1.items.add(' PRINTER_ATTRIBUTE_QUEUED');
if TPrinterInfo2A(Buffer^).Attributes and PRINTER_ATTRIBUTE_QUEUED = PRINTER_ATTRIBUTE_QUEUED then
ListBox1.items.add(' PRINTER_ATTRIBUTE_QUEUED');
if TPrinterInfo2A(Buffer^).Attributes and PRINTER_ATTRIBUTE_DIRECT = PRINTER_ATTRIBUTE_DIRECT then
ListBox1.items.add(' PRINTER_ATTRIBUTE_DIRECT');
if TPrinterInfo2A(Buffer^).Attributes and PRINTER_ATTRIBUTE_DEFAULT = PRINTER_ATTRIBUTE_DEFAULT then
ListBox1.items.add(' PRINTER_ATTRIBUTE_DEFAULT');
if TPrinterInfo2A(Buffer^).Attributes and PRINTER_ATTRIBUTE_SHARED = PRINTER_ATTRIBUTE_SHARED then
ListBox1.items.add(' PRINTER_ATTRIBUTE_SHARED');
if TPrinterInfo2A(Buffer^).Attributes and PRINTER_ATTRIBUTE_NETWORK = PRINTER_ATTRIBUTE_NETWORK then
ListBox1.items.add(' PRINTER_ATTRIBUTE_NETWORK');
if TPrinterInfo2A(Buffer^).Attributes and PRINTER_ATTRIBUTE_HIDDEN = PRINTER_ATTRIBUTE_HIDDEN then
ListBox1.items.add(' PRINTER_ATTRIBUTE_HIDDEN');
if TPrinterInfo2A(Buffer^).Attributes and PRINTER_ATTRIBUTE_LOCAL = PRINTER_ATTRIBUTE_LOCAL then
ListBox1.items.add(' PRINTER_ATTRIBUTE_LOCAL');
if TPrinterInfo2A(Buffer^).Attributes and PRINTER_ATTRIBUTE_ENABLE_DEVQ = PRINTER_ATTRIBUTE_ENABLE_DEVQ then
ListBox1.items.add(' PRINTER_ATTRIBUTE_ENABLE_DEVQ');
if TPrinterInfo2A(Buffer^).Attributes and PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS = PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS then
ListBox1.items.add(' PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS');
if TPrinterInfo2A(Buffer^).Attributes and PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST = PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST then
ListBox1.items.add('PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST');
if TPrinterInfo2A(Buffer^).Attributes and PRINTER_ATTRIBUTE_WORK_OFFLINE = PRINTER_ATTRIBUTE_WORK_OFFLINE then
ListBox1.items.add(' PRINTER_ATTRIBUTE_WORK_OFFLINE');
if TPrinterInfo2A(Buffer^).Attributes and PRINTER_ATTRIBUTE_ENABLE_BIDI = PRINTER_ATTRIBUTE_ENABLE_BIDI then
ListBox1.items.add(' PRINTER_ATTRIBUTE_ENABLE_BIDI');
ListBox1.items.add('Priority='+inttostr(TPrinterInfo2A(Buffer^).Priority));
ListBox1.items.add('DefaultPriority='+inttostr(TPrinterInfo2A(Buffer^).DefaultPriority));
ListBox1.items.add('StartTime='+inttostr(TPrinterInfo2A(Buffer^).StartTime));
ListBox1.items.add('UntilTime='+inttostr(TPrinterInfo2A(Buffer^).UntilTime));
ListBox1.items.add('Status='+inttostr(TPrinterInfo2A(Buffer^).Status));
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_PAUSED = PRINTER_STATUS_PAUSED then
ListBox1.items.add(' PRINTER_STATUS_PAUSED');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_ERROR = PRINTER_STATUS_ERROR then
ListBox1.items.add(' PRINTER_STATUS_ERROR');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_PENDING_DELETION = PRINTER_STATUS_PENDING_DELETION then
ListBox1.items.add(' PRINTER_STATUS_PENDING_DELETION');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_PAPER_JAM = PRINTER_STATUS_PAPER_JAM then
ListBox1.items.add(' PRINTER_STATUS_PAPER_JAM');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_PAPER_OUT = PRINTER_STATUS_PAPER_OUT then
ListBox1.items.add(' PRINTER_STATUS_PAPER_OUT');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_MANUAL_FEED = PRINTER_STATUS_MANUAL_FEED then
ListBox1.items.add(' PRINTER_STATUS_MANUAL_FEED');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_PAPER_PROBLEM = PRINTER_STATUS_PAPER_PROBLEM then
ListBox1.items.add(' PRINTER_STATUS_PAPER_PROBLEM');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_OFFLINE = PRINTER_STATUS_OFFLINE then
ListBox1.items.add(' PRINTER_STATUS_OFFLINE');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_IO_ACTIVE = PRINTER_STATUS_IO_ACTIVE then
ListBox1.items.add(' PRINTER_STATUS_IO_ACTIVE');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_BUSY = PRINTER_STATUS_BUSY then
ListBox1.items.add(' PRINTER_STATUS_BUSY');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_PRINTING = PRINTER_STATUS_PRINTING then
ListBox1.items.add(' PRINTER_STATUS_PRINTING');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_OUTPUT_BIN_FULL = PRINTER_STATUS_OUTPUT_BIN_FULL then
ListBox1.items.add(' PRINTER_STATUS_OUTPUT_BIN_FULL');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_NOT_AVAILABLE = PRINTER_STATUS_NOT_AVAILABLE then
ListBox1.items.add(' PRINTER_STATUS_NOT_AVAILABLE');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_WAITING = PRINTER_STATUS_WAITING then
ListBox1.items.add(' PRINTER_STATUS_WAITING');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_PROCESSING = PRINTER_STATUS_PROCESSING then
ListBox1.items.add(' PRINTER_STATUS_PROCESSING');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_INITIALIZING = PRINTER_STATUS_INITIALIZING then
ListBox1.items.add(' PRINTER_STATUS_INITIALIZING');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_WARMING_UP = PRINTER_STATUS_WARMING_UP then
ListBox1.items.add(' PRINTER_STATUS_WARMING_UP');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_TONER_LOW = PRINTER_STATUS_TONER_LOW then
ListBox1.items.add(' PRINTER_STATUS_TONER_LOW');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_NO_TONER = PRINTER_STATUS_NO_TONER then
ListBox1.items.add(' PRINTER_STATUS_NO_TONER');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_PAGE_PUNT = PRINTER_STATUS_PAGE_PUNT then
ListBox1.items.add(' PRINTER_STATUS_PAGE_PUNT');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_USER_INTERVENTION = PRINTER_STATUS_USER_INTERVENTION then
ListBox1.items.add(' PRINTER_STATUS_USER_INTERVENTION');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_OUT_OF_MEMORY = PRINTER_STATUS_OUT_OF_MEMORY then
ListBox1.items.add(' PRINTER_STATUS_OUT_OF_MEMORY');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_DOOR_OPEN = PRINTER_STATUS_DOOR_OPEN then
ListBox1.items.add(' PRINTER_STATUS_DOOR_OPEN');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_SERVER_UNKNOWN = PRINTER_STATUS_SERVER_UNKNOWN then
ListBox1.items.add(' PRINTER_STATUS_SERVER_UNKNOWN');
if TPrinterInfo2A(Buffer^).Status and PRINTER_STATUS_POWER_SAVE = PRINTER_STATUS_POWER_SAVE then
ListBox1.items.add(' PRINTER_STATUS_POWER_SAVE');
ListBox1.items.add('cJobs='+inttostr(TPrinterInfo2A(Buffer^).cJobs));
ListBox1.items.add('AveragePPM='+inttostr(TPrinterInfo2A(Buffer^).AveragePPM));
end;
FreeMem(Buffer, pcbNeed);
end;
Procedure TForm1.ShowPrinterStatus( const PrinterName : String );
Var
PrinterInfo: PPrinterInfo2;
PrinterHandle : THandle;
Stat : LongBool;
requiredSize : Cardinal;
Begin
Try
Stat := OpenPrinter( PChar(PrinterName), PrinterHandle, NIL );
//This works fine
If ( Stat )
Then
Begin
Try
GetMem( PrinterInfo, 1024 );
Stat := GetPrinter(PrinterHandle, 2, PrinterInfo, 1024,
@requiredSize );
Edit2.Text := 'Printer Name Is: ' + PrinterInfo^.pPrinterName;
Form1.Caption := inttostr(PrinterInfo^.Attributes);
Case PrinterInfo^.Status of
0 : Edit1.Text := 'Printer Ready!';
PRINTER_STATUS_DOOR_OPEN : Edit1.Text := 'Door Open';
PRINTER_STATUS_POWER_SAVE : Edit1.Text := 'Power SaveMode';
PRINTER_STATUS_WARMING_UP : Edit1.Text := 'Warming Up';
PRINTER_STATUS_PAPER_OUT : Edit1.Text := 'Out of Paper';
End;
Finally
FreeMem( PrinterInfo, 1024 );
End;
End
Else
Begin
Edit1.Text := 'NA';
Edit2.Text := 'Cannot Open Printer: ' + PrinterName;
End;
Finally
ClosePrinter( PrinterHandle );
End;
End; |
|
#8
|
|||
|
|||
|
Код:
function GetPrinterStatus(const APrinterIndex: Integer): DWORD;
var
APrinterHandle: THandle;
APrinterInfo: PPrinterInfo2;
ABytesNeeded: DWORD;
function GetPrinterHandle: THandle;
const
PrinterDefaults: TPrinterDefaults = (
pDatatype: nil; pDevMode: nil; DesiredAccess: PRINTER_ACCESS_USE or PRINTER_ACCESS_ADMINISTER
);
var
ADevice, ADriver, APort: array[0..MAX_PATH] of Char;
hDeviceMode: THandle;
begin
Printer.GetPrinter(ADevice, ADriver, APort, hDeviceMode);
if not OpenPrinter(@ADevice, Result, @PrinterDefaults) then
RaiseLastOSError;
end;
begin
Result := 0;
APrinterHandle := 0;
try
Printer.PrinterIndex := 1;
APrinterHandle := GetPrinterHandle;
ABytesNeeded := 0;
if not WinSpool.GetPrinter(APrinterHandle, 2, nil, 0, @ABytesNeeded) then
if Windows.GetLastError <> ERROR_INSUFFICIENT_BUFFER then
RaiseLastOSError;
GetMem(APrinterInfo, ABytesNeeded);
try
if not WinSpool.GetPrinter(APrinterHandle, 2, APrinterInfo, ABytesNeeded, @ABytesNeeded) then
RaiseLastOSError;
Result := APrinterInfo^.Status;
finally
begin
FreeMem(APrinterInfo);
Form1.Caption := inttostr(APrinterInfo^.Attributes);
end;
end;
except on E: Exception do
begin
if APrinterHandle <> 0 then
ClosePrinter(APrinterHandle);
raise;
end;
end;
end; |
|
#9
|
|||
|
|||
|
Я в программе, которая с принтером шла отключил оповещение компьютера принтером. Может она влиять на то, что моя программа не видит сообщения от принтера?
|
|
#10
|
|||
|
|||
|
может. включи и попробуй.
|