<div dir="ltr">Hi,<div><br></div><div>map the USB Port to a Virtual Serial Port and open the Port as File using CreateFile using name "\\.\COMxxx"</div><div>Then write to the port with the usual API file commands</div><div><br></div><div>Even better wrap  this to a Stream (or FileStream) descendant and use Stream.Write commands</div><div>Read and Seek should do nothing</div><div><br></div><div>I hope this helps</div><div><br></div><div>Chriss</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 13, 2015 at 3:13 PM, Virgo Pärna <span dir="ltr"><<a href="mailto:virgo.parna@mail.ee" target="_blank">virgo.parna@mail.ee</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, 13 Jan 2015 10:41:55 -0200, Philippe <<a href="mailto:philippe@quarta.com.br">philippe@quarta.com.br</a>> wrote:<br>
><br>
> First: could anyone tell me I have the possibility to access USB<br>
> printer in raw mode with the "basic" FPC package (not using Lazarus<br>
> packages/components)?<br>
><br>
<br>
</span>    If you have USB printer installed , then winunits-base package has winspool unit.<br>
    Following sample is with string beeing ansisstring and Char AnsiChar.<br>
<br>
procedure PrintCodesToPrinter(const APrinterName, APrintData: string);<br>
type<br>
  TDoc_Info_1 = record<br>
    DocName,<br>
    OutputFile,<br>
    Datatype: PChar;<br>
  end;<br>
var<br>
  Written: DWORD;<br>
  DocInfo: TDoc_Info_1;<br>
  PHandle: THandle;<br>
begin<br>
  if APrintData = '' then //nothing to print<br>
    exit;<br>
  DocInfo.DocName := 'POS';<br>
  DocInfo.OutputFile := nil;<br>
  DocInfo.Datatype := 'RAW';<br>
  if not OpenPrinter(PChar(APrinterName), PHandle, nil) then<br>
    raise Exception.CreateFmt('Error opening printer "%s"',<br>
[APrinterName]);<br>
  try<br>
    StartDocPrinter(PHandle, 1, @DocInfo);<br>
    StartPagePrinter(PHandle);<br>
    WritePrinter(PHandle, @APrintData[1], Length(APrintData), Written);<br>
    EndPagePrinter(PHandle);<br>
    EndDocPrinter(PHandle);<br>
  finally<br>
    ClosePrinter(PHandle);<br>
  end;<br>
end;<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Virgo Pärna<br>
<a href="mailto:virgo.parna@mail.ee">virgo.parna@mail.ee</a><br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
fpc-pascal maillist  -  <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a></div></div></blockquote></div><br></div>