I want to send mark to parallel port using C++ in winXP system. I checked the information and wrote the following code:
HANDLE parallelPort = CreateFile(L"LPT1", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if(parallelPort == INVALID_HANDLE_VALUE)
std::cout << "handle error" << std::endl;
int *data = new int[1];
data[0] = 4;
WriteFile(parallelPort, data, sizeof(int), NULL, NULL);
std::cout << "send success!" << std::endl;
CloseHandle(parallelPort);
I run this code, find parallelPort != INVALID_HANDLE_VALUE
. But it doesn't print send success!
. What's wrong with this code?
If you have used the software named "E-prime", I want to do the same as it:
WritePort &H378, 0