直接驱动并口(串口),用字符方式打印,请问,有否这方面的DLL或构件?(300分)

  • 主题发起人 主题发起人 wghua
  • 开始时间 开始时间
W

wghua

Unregistered / Unconfirmed
GUEST, unregistred user!
WINDOW下用图形打印较DOS下用字符打印慢,我想直接驱动并口(串口),用字符方式打印,请问,有否这方面的DLL或构件,最好已有直接能驱动LQ1600K打印机的例程。
 
起先以为很难,其实还可以.参阅了DFW们的回答,像在DOS下一样,直接控制打印机完全可以,我用的是Star 2400打印机
方法1
procedure WriteRawStringToPrinter(PrinterName:String;
S:String);
var
Handle: THandle;
N: DWORD;
do
cInfo1: TDocInfo1;
begin

if not OpenPrinter(PChar(PrinterName), Handle, nil) then

begin

ShowMessage('error ' + IntToStr(GetLastError));
Exit;
end;

withdo
cInfo1do
begin

pDocName := PChar('testdo
c');
pOutputFile := nil;
pDataType := 'RAW';
end;

StartDocPrinter(Handle, 1, @DocInfo1);
StartPagePrinter(Handle);
WritePrinter(Handle, PChar(S), Length(S), N);
EndPagePrinter(Handle);
EndDocPrinter(Handle);
ClosePrinter(Handle);
end;


procedure TForm1.Button1Click(Sender: TObject);
var s:string;
begin

s:=#27#117+'2'+'中国人民24X16'+#10;
WriteRawStringToPrinter('Star 2400',#26#78+'字间距3'+#10);
WriteRawStringToPrinter('Star 2400',#26#81+'字间距0'+#10);
WriteRawStringToPrinter('Star 2400',#27#48+'行距1/6'+#10);
WriteRawStringToPrinter('Star 2400',S);
WriteRawStringToPrinter('Star 2400',#27#117+'1'+'恢复24X24'+#10);
WriteRawStringToPrinter('Star 2400',#27#50+'行距1/8'+#10);
WriteRawStringToPrinter('Star 2400',#26#81+'中国人民'+#10);
WriteRawStringToPrinter('Star 2400',#28#14+'横向放大'+#10);
WriteRawStringToPrinter('Star 2400',#27#118+'逆向走纸');
WriteRawStringToPrinter('Star 2400',#10);
WriteRawStringToPrinter('Star 2400',' 定位');
WriteRawStringToPrinter('Star 2400',#27#102);
WriteRawStringToPrinter('Star 2400',#10#10+'正常走纸'+#10);
WriteRawStringToPrinter('Star 2400',' 定位'+#10);
end;


方法2
procedure TForm1.Button2Click(Sender: TObject);
var
F: TextFile;
begin

AssignFile(F, 'LPT1');
Rewrite(F);
Writeln(F, #26#78+'字间距3');
Writeln(F, #26#81+'字间距0');
Writeln(F, #27#48+'行距1/6');
Writeln(F, #27#117+'2'+'中国人民24X16');
Writeln(F, #27#117+'1'+'恢复24X24');
Writeln(F, #27#50+'行距1/8');
Writeln(F, #28#14+'横向放大');
Writeln(F, #27#118+'逆向走纸');
Writeln(F, ' 定位');
Writeln(F, #27#102);
Writeln(F, #10#10+'正常走纸');
Writeln(F, ' 定位');
CloseFile(F);
end;

 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部