Jump to content
  • Advertisement
Sign in to follow this  

Printing To Windows Spooler

This topic is 3924 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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!