Prev: DevStudio question
Next: Update multiple row
From: jonathan on 28 May 2010 05:14 Hello How Send Raw Data to a Printer from TSE ? I've tried with this function, but it does not work. I get an error with Windows "Presentation Foundation Terminal Server Print W" BOOL RawDataToPrinter(LPSTR szPrinterName, LPBYTE lpData, DWORD dwCount) { HANDLE hPrinter; DOC_INFO_1 DocInfo; DWORD dwJob; DWORD dwBytesWritten; // Need a handle to the printer. if( ! OpenPrinter( szPrinterName, &hPrinter, NULL ) ) return FALSE; // Fill in the structure with info about this "document." DocInfo.pDocName = "My Document"; DocInfo.pOutputFile = NULL; DocInfo.pDatatype = "RAW"; // Inform the spooler the document is beginning. if( (dwJob = StartDocPrinter( hPrinter, 1, (LPSTR)&DocInfo )) == 0 ) { ClosePrinter( hPrinter ); return FALSE; } // Start a page. if( ! StartPagePrinter( hPrinter ) ) { EndDocPrinter( hPrinter ); ClosePrinter( hPrinter ); return FALSE; } // Send the data to the printer. if( !WritePrinter( hPrinter, lpData, dwCount, &dwBytesWritten ) ) { EndPagePrinter( hPrinter ); EndDocPrinter( hPrinter ); ClosePrinter( hPrinter ); return FALSE; } // End the page. if( ! EndPagePrinter( hPrinter ) ) { EndDocPrinter( hPrinter ); ClosePrinter( hPrinter ); return FALSE; } // Inform the spooler that the document is ending. if( ! EndDocPrinter( hPrinter ) ) { ClosePrinter( hPrinter ); return FALSE; } // Tidy up the printer handle. ClosePrinter( hPrinter ); // Check to see if correct number of bytes were written. if( dwBytesWritten != dwCount ) return FALSE; return TRUE; }
|
Pages: 1 Prev: DevStudio question Next: Update multiple row |