Sign in to follow this  

Printing To Windows Spooler

This topic is 3588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Copied this straight from Microsoft's MSDN site. http://msdn2.microsoft.com/en-us/library/ms535786(VS.85).aspx Would someone please give me some kind of explanation that will help me understand why it doesn't work. I keep getting a message from the spooler that states "Local Downlevel Document" <source> int CPrinter::WriteBuffer(char* str) { // clear out a print buffer memset(errBuffer, 0x20, MAX_LONG_STRING_LENGTH); // format the time for the log entry time.FormatTime(timeBuffer); // build the line int x = 0; while(timeBuffer[x] > 0x19) { errBuffer[x] = timeBuffer[x]; x++; } x = 10; int y = 0; while(str[y] != 0x00) { errBuffer[x] = str[y]; x++; y++; } errBuffer[x] = str[y]; int bStatus = FALSE; HANDLE hPrinter = NULL; DOC_INFO_1 DocInfo; DWORD dwJob = 0L; DWORD dwBytesWritten = 0L; char szPrinterName[] = "HP Deskjet 3900 Series"; // Open a handle to the printer. bStatus = OpenPrinter( (LPTSTR)szPrinterName, &hPrinter, NULL ); if (bStatus) { // Fill in the structure with info about this "document." DocInfo.pDocName = (LPTSTR)_T("Flipidi Floop"); DocInfo.pOutputFile = NULL; DocInfo.pDatatype = (LPTSTR)_T("RAW"); // Inform the spooler the document is beginning. dwJob = StartDocPrinter( hPrinter, 1, (LPBYTE)&DocInfo ); if (dwJob > 0) { // Start a page. bStatus = StartPagePrinter( hPrinter ); if (bStatus) { // Send the data to the printer. // bStatus = WritePrinter( hPrinter, lpData, dwCount, &dwBytesWritten); bStatus = WritePrinter( hPrinter, str, 1, &dwBytesWritten); bStatus = EndPagePrinter (hPrinter); } // Inform the spooler that the document is ending. bStatus = EndDocPrinter( hPrinter ); } // Close the printer handle. ClosePrinter( hPrinter ); } // Check to see if correct number of bytes were written. // if (!bStatus || (dwBytesWritten != dwCount)) { if (!bStatus || (dwBytesWritten != 1)) { bStatus = FALSE; } else { bStatus = TRUE; } return bStatus; return TRUE; } </source>

Share this post


Link to post
Share on other sites

This topic is 3588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this