If you only want to print text using the printer built-in character sets, you can directly write to the printer by opening
LPTx with
CreateFile
and using
WriteFile
.
This requires that you setup and control the printer using the
Epson ESC/P[
^] command set.
Then print your text and apply line or page feeds according to your requirements and the paper size.
[UPDATE: Example code]
I have not used ESC/P printing since DOS times. This is untested.
HANDLE hPort = CreateFile(_T("LPT1:"), GENERIC_WRITE, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hPort != INVALID_HANDLE_VALUE)
{
char lpszCmd[] = "Test\r\n";
DWORD dwWritten;
WriteFile(hPort, lpszCmd, strlen(lpszCmd), &dwWritten, NULL);
CloseHandle(hPort);
}
[UPDATE 2]
The Windows API provides functions to perform direct printing by opening with the printer's name:
OpenPrinter
,
WritePrinter
, and
ClosePrinter
.
Just use these instead of the above I/O functions.