I'm writing a program which reads from file and send to printer to print.
I set "HP Laser Jet 4" as default printer and checked "LPT1" in printer properties of "HP Laser Jet 4". Print spooler is also running (Windows 7).
The problem is hPort always returns INVALID_HANDLE_VALUE
.
I don't have a real printer. Is it a problem?
#include "stdafx.h"
#include <windows.h>
int main()
{
HANDLE hPort = CreateFile(_T("LPT1:"), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hPort != INVALID_HANDLE_VALUE) {
printf("success");
} else {
printf("%i", GetLastError());
}
return 0;
}