S
smallfox
Unregistered / Unconfirmed
GUEST, unregistred user!
我运行如下代码时,如果小票打印机没开机,电脑就会死机,清问该如何解决
procedure TFormMain.PrintFile(AFileToPrint: string);
var
Port, FileToPrint: TextFile;
ALine: string;
begin
AssignFile(FileToPrint, AFileToPrint);
Reset(FileToprint);
AssignFile(Port, 'LPT1');
Rewrite(Port);
while not Eof(FileToPrint)do
begin
Readln(FileToPrint, ALine);
Writeln(Port, ALine);
end;
CloseFile(Port);
CloseFile(FileToPrint);
end;
procedure TFormMain.PrintFile(AFileToPrint: string);
var
Port, FileToPrint: TextFile;
ALine: string;
begin
AssignFile(FileToPrint, AFileToPrint);
Reset(FileToprint);
AssignFile(Port, 'LPT1');
Rewrite(Port);
while not Eof(FileToPrint)do
begin
Readln(FileToPrint, ALine);
Writeln(Port, ALine);
end;
CloseFile(Port);
CloseFile(FileToPrint);
end;