Well, I got the program to compile with no errors. And all my function calls indicate success. But there is no output from the printer. I though that I would try the FlushPrinter function to empty the buffer but I got a 'FlushPrinter Undeclaired' error, So I guess my winspool library does not contain that function? Is there something with the code I am not seeing or is it something with my OS (windows XP) that I need to look at?
Code:
int main()
{
int p;
char test[] = "This is a test line to be printed.";
char printername[] = "HP DeskJet 712C";
char docname[] = "Print Test";
LPTSTR pPrinterName = printername;
LPVOID pBuf = test;
DWORD cbBuf = sizeof(test);
DWORD Level = 1;
DWORD Written;
HANDLE hPrinter;
DOC_INFO_1 pDocInfo;
pDocInfo.pDocName = docname;
pDocInfo.pOutputFile = NULL;
pDocInfo.pDatatype = NULL;
OpenPrinter(pPrinterName, &hPrinter, NULL);
StartDocPrinter(hPrinter, Level, (BYTE*)&pDocInfo);
StartPagePrinter(hPrinter);
WritePrinter(hPrinter, pBuf, cbBuf, &Written);
FlushPrinter(hPrinter, pBuf, cbBuf, &Written, cSleep);
EndPagePrinter(hPrinter);
EndDocPrinter(hPrinter);
ClosePrinter(hPrinter);
cout<<endl
<<"Test line sent to printer"<<endl
<<"Hit <enter> to end";
cin.get();
return 0;
}