How to change the ReadyMessage of HP-LaserJet printers (Views: 731)
Problem/Question/Abstract: How to change the ReadyMessage of HP-LaserJet printers with a LCD display? Answer: This works only on HP-LaserJet printers, which have a two line 16 character LCD display. F.i. on a HP LaserJet 4000, HP LaserJet 5000 (N). In this LCD-display you normally find messages like: READY, or PAPER OUT IN BIN 3 or something like that. With this small routine you can alter the ready message into your own. It will stay there until you switch the printer off (or change the ready message with this program). The message should be no longer than two lines of 16 characters each. Remember that it will be truncated after 16 characters, the rest of the line will be on the next line of 16 characters on the LCD display. //---------------------------------------------------------------------- // This routine is published by me before... procedure PrintRawStr(const S: ANSIString); Uses Printers, WinSpool, Dialogs; var Handle: THandle; dwN: DWORD; diDocInfo1: TDocInfo1; bP: BYTE; sDefaultPrinter: string; begin sDefaultPrinter := ''; if Printer.Printers.Count > 0 then begin sDefaultPrinter := Printer.Printers[Printer.PrinterIndex]; //uses Printers, get default printer bP := Pos(' on ', sDefaultPrinter); if bP > 0 then sDefaultPrinter := Copy(sDefaultPrinter, 1, bP - 1); end; if Length(S) = 0 then Exit; if not OpenPrinter(PChar(sDefaultPrinter), Handle, nil) then begin case GetLastError of 87: ShowMessage('Printer name does not exists.'); else ShowMessage('Error ' + IntToStr(GetLastError)); // Uses Dialogs end; Exit; end; with diDocInfo1 do begin pDocName := PChar('My Print Job'); // Visible in the spooler window pOutputFile := nil; pDataType := 'RAW'; end; StartDocPrinter(Handle, 1, @diDocInfo1); StartPagePrinter(Handle); WritePrinter(Handle, PChar(S), Length(S), dwN); EndPagePrinter(Handle); EndDocPrinter(Handle); ClosePrinter(Handle); end; //---------------------------------------------------------------------- procedure ChangeLaserReadyMessage(S: string); const InitStr: string = #27 + '%-12345X@PJL RDYMSG DISPLAY="'; ExitStr: string = '"' + #13 + #10 + #27 + '%-12345X' + #13 + #10; begin PrintRawStr(InitStr + S + ExitStr); end; //---------------------------------------------------------------------- |