procedure PrintInvoice(AText: String);
var
buff : PByte;
FH: THandle;
sOutPut: String;
lenBuff: Integer;
RetW: DWORD;
begin
sOutput :=UTF8ToConsole(AText);
lenBuff:=Length(sOutput);
FH:= CreateFile('COM9:', GENERIC_READ or GENERIC_WRITE, 0, Nil, OPEN_EXISTING, 0, 0);
if (FH = INVALID_HANDLE_VALUE) then
ShowMessage('Invalid handle!')
else begin
try
Buff:=PByte(@sOutput[1]);
WriteFile(FH, buff^, lenBuff, RetW, Nil);
if Integer(RetW) = lenBuff then
ShowMessage('Printed!');
finally
Windows.CloseHandle(FH);
end;
end;