一台微型POS用打印机连接在打印口上。
请问DEPHI中有那些命令能控制这个口呢!!
都否给出原形~~~~
多谢各位高手了
请问DEPHI中有那些命令能控制这个口呢!!
都否给出原形~~~~
多谢各位高手了
解决方案 »
- 怎样隐藏没有标题文本的软件
- 有做过用友ERP二次开发的朋友过来看看啊。。。
- 如何实现关闭含有指定文字的程序窗口?
- 急!如何在delphi中把从数据库中读取的数据显示成pb中数据窗口的lable格式?
- 有急用!!!如何对*.txt(文本文件)进行操作!!!!谢谢诸位老大啊!!!
- 关于软件加密狗如何控制功能模块问题?请教各位高手如何解决。
- 伤感中,谁是浪漫的程序员?
- InfoPower3000Pro_vcl6和InfoPower2000Pro_vcl5的密码是什么
- 如何象Word那样,制作一个“窗口”菜单项
- 访问网络数据库,访问被拒绝。但在用户机上建立odbc 数据源文件,就可以使用了。
- 请教.
- 小弟对Delphi一无所知,请各位GG、JJ请帮忙!!!
PrnFileName: TextFile;
begin
Assignfile(PrnFileName,'lpt1');
Rewrite(PrnFileName); write(PRNFileName,'123');
CloseFile(PRNFileName);
end;
PrnFileName: TextFile;
begin
Assignfile(PrnFileName,'lpt1');
Rewrite(PrnFileName); write(PRNFileName,CHR(27)+'p'+CHR(0)+CHR(60)+CHR(255) );
CloseFile(PRNFileName);
end;
PrnFileName: TextFile;
begin
Assignfile(PrnFileName,'lpt1');
Rewrite(PrnFileName); write(PRNFileName,CHR(27)+'p'+CHR(0)+CHR(60)+CHR(255) );
CloseFile(PRNFileName);
end;
在BCB中经常也看到你,以前经常混那里!!
不知道你说的 escape
是什么意思呢?能否再行解释一下
int nEscape, // escape function
int cbInput, // number of bytes in input structure
LPCSTR lpvInData, // pointer to input structure
LPVOID lpvOutData // pointer to output structure
);
bypassing the printer driver. Ideal for bar code printers and other stuff.
Modelled by [email protected]
This code is GPL.
HOWTO:
MyPrinter := TRawPrint.Create(nil);
MyPrinter.DeviceName := 'HP LaserJet Series II';
MyPrinter.JobName := 'MyJob';
if MyPrinter.OpenDevice then
begin
MyPrinter.WriteString('This is page 1');
MyPrinter.NewPage;
MyPrinter.WriteString('This is page 2');
MyPrinter.CloseDevice;
end;
MyPrinter.Destroy;
}// {$ASSERTIONS OFF}interfaceuses
Windows, WinSpool, Printers, Dialogs, Classes;type
TError = procedure(Sender: TObject; var ErrorMessage: String) of object;
TRawPrint = class(TComponent)
private
{ Private declarations }
MyDeviceName: String;
MyJobName: String;
MyError: TError;
hPrinter: Cardinal;
IsOpenDevice: Boolean;
IsOpenPage: Boolean;
protected
{ Protected declarations }
function GetLastErrMsg: String;
procedure RaiseError(ErrMsg: String);
public
{ Public declarations }
function OpenDevice: Boolean;
function CloseDevice: Boolean;
function WriteString(Text: String): Boolean;
function NewPage: Boolean;
procedure SelectPrinter;
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property DeviceName: String read MyDeviceName write MyDeviceName;
property JobName: String read MyJobName write MyJobName;
property OnError: TError read MyError write MyError;
end;procedure Register;implementationconstructor TRawPrint.Create(AOwner : TComponent);
begin
inherited;
MyDeviceName := Printer.Printers.Strings[Printer.PrinterIndex];
MyJobName := 'RawPrint';
IsOpenDevice := False;
IsOpenPage := False;
end;destructor TRawPrint.Destroy;
begin
if IsOpenDevice then CloseDevice;
inherited;
end;procedure Register;
begin
RegisterComponents('[email protected]', [TRawPrint]);
end;function TRawPrint.OpenDevice: Boolean;
type _DocInfo = record
pDocName: PAnsiChar;
pOutputFile: PAnsiChar;
pDatatype: PAnsiChar;
end;
var DocInfo: _DocInfo;
begin
Result := True;
if not OpenPrinter(PChar(DeviceName), hPrinter, nil) then begin
RaiseError(GetLastErrMsg);
Result := False;
end else begin
DocInfo.pDocName := pChar(JobName);
DocInfo.pOutputFile := pChar(#0);
DocInfo.pDatatype := pChar(#0);
if StartDocPrinter(hPrinter, 1, @DocInfo) = 0 then begin
RaiseError(GetLastErrMsg);
ClosePrinter(hPrinter);
Result := False;
end else begin
IsOpenDevice := True;
NewPage;
end;
end;
end;function TRawPrint.NewPage: Boolean;
begin
Result := True;
if IsOpenDevice then begin
if IsOpenPage then begin
if not EndPagePrinter(hPrinter) then begin
RaiseError(GetLastErrMsg);
end;
end;
if not StartPagePrinter(hPrinter) then begin
RaiseError(GetLastErrMsg);
Result := False;
end else begin
IsOpenPage := True;
end;
end;
end;function TRawPrint.WriteString(Text: String): Boolean;
var WrittenChars: Cardinal;
begin
Result := False;
if IsOpenDevice then begin
Result := True;
if not WritePrinter(hPrinter, PChar(Text), Length(Text), WrittenChars) then begin
RaiseError(GetLastErrMsg);
Result := False;
end;
end;
end;function TRawPrint.CloseDevice: Boolean;
begin
Result := True;
if IsOpenDevice then begin
if IsOpenPage then begin;
if not EndPagePrinter(hPrinter) then begin
RaiseError(GetLastErrMsg);
end;
end;
if not EndDocPrinter(hPrinter) then begin
RaiseError(GetLastErrMsg);
Result := False;
end else begin
if not ClosePrinter(hPrinter) then begin
RaiseError(GetLastErrMsg);
Result := False;
end else begin
Result := True; IsOpenDevice := False;
end;
end;
end;
end;procedure TRawPrint.RaiseError(ErrMsg: String);
begin
if Assigned(OnError) then MyError(Self,ErrMsg);
end;function TRawPrint.GetLastErrMsg: String;
var Buf: Array[0..499] of char;
BufLen: Integer;
begin
BufLen := FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nil, GetLastError, 0, Buf, SizeOf(Buf), nil);
Result := Copy(Buf, 1, BufLen);
end;Procedure TRawPrint.SelectPrinter;
var PrtDlg: TPrintDialog;
begin
PrtDlg := TPrintDialog.Create(Self);
prtdlg.Options := [poPrintToFile];
if PrtDlg.Execute then begin
DeviceName := Printer.Printers.Strings[Printer.PrinterIndex];
end;
PrtDlg.Free;
end;end.
PrnFileName: TextFile;
begin
Assignfile(PrnFileName,MoneyPort);
Rewrite(PrnFileName); write(PRNFileName,CHR(27)+'p'+CHR(0)+CHR(60)+CHR(255) );
CloseFile(PRNFileName);
end;
PrnFileName: TextFile;
begin
Assignfile(PrnFileName,MoneyPort);
Rewrite(PrnFileName); write(PRNFileName,CHR(27)+'p'+CHR(0)+CHR(60)+CHR(255) );
CloseFile(PRNFileName);
end;
PrnFileName: TextFile;
begin
Assignfile(PrnFileName,MoneyPort);
Rewrite(PrnFileName); write(PRNFileName,CHR(27)+'p'+CHR(0)+CHR(60)+CHR(255) );
CloseFile(PRNFileName);
end;