Correct way to send commands directly to printer!

前端 未结 3 1621
夕颜
夕颜 2021-01-03 12:04

Ok, here is how i do it:

procedure TMainWindow.btnRawPrintClick(Sender: TObject);
begin
  BeginPrint;
  SendStr(#27#69);
  SendStr(\'MyData\');
  SendStr(#10         


        
3条回答
  •  孤街浪徒
    2021-01-03 12:43

    Procedure StrLstYazdir(pYazilacakListe: TStringList; pYazici: String);
    var
      hPrn: THandle;
      yazilacakVeri: AnsiString;
      intA: Integer;
    begin
      hPrn := StartRawPrintJob(PChar(pYazici), '', 'Varakim');
      if (Integer(hPrn) < 0) then
      Begin
        ShowMessage('StartRawPrintJob Hatalı');
        Exit;
      End;
    
      if (StartRawPrintPage(hPrn) < 0) then
      Begin
        ShowMessage('StartRawPrintPage Hatalı');
        EndRawPrintJob(hPrn);
        Exit;
      end;
    
      For intA := 0 to pYazilacakListe.Count - 1 do
      Begin
        yazilacakVeri := pYazilacakListe[intA] + #13 + #10;
    
        if (PrintRawData(hPrn, PAnsiChar(yazilacakVeri), Length(yazilacakVeri)) < 0)
        then
        begin
          ShowMessage('PrintRawData Hatalı');
          EndRawPrintPage(hPrn);
          EndRawPrintJob(hPrn);
          Exit;
        End;
      End;
      if (EndRawPrintPage(hPrn) < 0) then
      begin
        ShowMessage('EndRawPrintPage Hatalı');
        EndRawPrintJob(hPrn);
        Exit;
      End;
    
      if (EndRawPrintJob(hPrn) < 0) then
      begin
        ShowMessage('EndRawPrintJob Hatalı');
        Exit;
      End;
    End;
    

    Usage:

    StrLstYazdir(Memo1.Lines ,'Lexmark Forms Printer 2491')
    

提交回复
热议问题