您好,请问哪位大神有利用delphi控制过条码打印机或钱柜的。我的打印机使用下列语句,一点反应都没有。但是如果把raw改成text,则打印机会直接将命令用文字的方式输出!
procedure WriteRawStringToPrinter(PrinterName, S: String);
var
Handle: THandle;
N: DWord;
DocInfo1: TDocInfo1A;
begin
if not OpenPrinter(PChar(PrinterName), Handle, nil) then raise Exception.Create('Open Printer Fail!');
with DocInfo1 do
begin
pDocName := PAnsiChar('BarCode Label');
pOutputFile := nil;
pDatatype := 'RAW';
end;
// 把換行及回車先處理掉試試
s := StringReplace(s,CHR(10),'',[rfReplaceAll]);
s := StringReplace(s,CHR(13),'',[rfReplaceAll]);
StartDocPrinter(Handle, 1, @DocInfo1);
StartPagePrinter(Handle);
//WritePrinter(Handle, PChar(S), Length(S), N);
WritePrinter(Handle, PChar('^XA^FO100,100^BY3^B3N,N,100,Y,N^FD123ABC^FS^XZ'), Length(S), N);
EndPagePrinter(Handle);
EndDocPrinter(Handle);
ClosePrinter(Handle);
end;