Click to See Complete Forum and Search --> : Problems in writing to LPT-port


Kim Hansen
April 6th, 1999, 07:29 AM
Hi

In my windows application I need to write some characters to my locale parallel-port.
This is a sample of the source code:

HANDLE hPort;
char szBuffer = "ABCDEF";
int nBytesToWrite;
DWORD dwBytesWritten;


nBytesToWrite = strlen (szBuffer);
hPort = CreateFile("LPT1", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
WriteFile(hPort, szBuffer, nBytesToWrite, &dwBytesWritten, NULL);
CloseHandle(hPort);

Unfortunately the character-string is not printed out immediately. The string is printed out when window is shutting down.

What am I doing wrong?????

Regards,
Kim Hansen








I’m using Visual C++ version 5.0 / MFC.

kapil
April 6th, 1999, 07:51 AM
i am also facing a pretty similar problem.
when i run my executable on wi n 95, it is able to access the serial port.
but when i run it onto win NT, it can't access the serial port..
i tried to run the program from the administrator's account also , but it failed again....
if you have any answers to this one , please mail me at kapma@hotmail.com

April 27th, 1999, 12:43 PM
Dear Kim,
I am trying to communicate with parallel port too, but I need you to tell me how it works. Can you send me more source code? Help me if you can and you will have a new friend in France!

My email: tan@ismea.imt-mrs.fr