I posted this recently in a different bulletin board about a similar topic. It might help.
To access the LPT or any COM port from C++ Builder, you need to use MFC functions. Use the following concept and functions:
DWORD
Errors,
dwdBytesSent,
dwdBytesRead;
COMSTAT
Status;
COMMTIMEOUTS
time_outs;
DCB
dcb;
char
chrSomeByte,
ptrSomeMultiBytePointer[400];
HANDLE PortHandle = CreateFile("LPT1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
GetCommState(PortHandle, &dcb);
SetupComm(PortHandle, 200, 200);
dcb.xxxx = xxxx;
/* Set dcb variables such as baud rate, stop bits, etc */
SetCommState(PortHandle, &dcb);
GetCommTimeouts(PortHandle, &time_outs);
time_outs.xxxx = xxxx;
/* Set comm timeouts for receive and transmit */
SetCommTimeouts(PortHandle, &time_outs);
PurgeComm(PortHandle, PURGE_TXCLEAR | PURGE_RXCLEAR | PURGE_TXABORT | PURGE_RXABORT);
ClearCommError(PortHandle, &Errors, &Status);
ClearCommBreak(PortHandle);
/* Run a separte thread that writes to the port when it's not being read from if you need asynchronous (easy way to do it) */
WriteFile(PortHandle, &chrSomeByte, 1, &dwdBytesSent, NULL);
/* Run a separate thread that reads from the port when it's not being written to (easy way) */
ReadFile(PortHandle, ptrSomeMultiBytePointer, 200, &dwdBytesRead, NULL);
CloseHandle(PortHandle);
This should work. Check out the Microsoft help file included with Borland for further info. Good luck.
Chris