I have an ancient POS printer Axhiohm A470 LINK. Windows 7 64bit doesn't detect this printer and drivers don't exist. Only way to print (text mode only) is to send print job directly to LPT. After some digging I found that it's pretty easy. Only thing you have to do is correctly create file LPT1 and write to it.
#include <iostream>
#include <conio.h>
#include <windows.h>
int main(int argc, char* argv[])
{
HANDLE hComm = CreateFileA("LPT1", GENERIC_READ | GENERIC_WRITE,
0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (hComm == INVALID_HANDLE_VALUE)
return 1;
char str[] = { " Hello from your printer\n" };
DWORD bytesWritten;
unsigned char data;
BOOL nError = WriteFile(hComm, str, sizeof(str), &bytesWritten, NULL);
if (nError)
std::cout << "Data sent" << std::endl;
else
std::cout << "Failed to write data " << GetLastError() << std::endl;
_getch();
}
Now I would like to take one step further and send print job to second feeder. First one is roll of paper inside the printer (prints receipt). This one prints by the code above. Second one is a slit that is used to put in another receipt. I don't know how to send print job there.