Click to See Complete Forum and Search --> : WritePrinter


jruck
October 18th, 1999, 09:44 AM
I am programming in V C++ 6.0. I put together the following code:


file.Open(FileName, CFile::modeRead);
DWORD dwNumBytes = file.GetLength();
UINT nBytesRead = file.ReadHuge( pbuf, dwNumBytes );


//SelectPrinter( NULL, NULL, TRUE );
if ( OpenPrinter( PrinterName, &hPrinter, NULL ) )
{

DOC_INFO_1 doc_info = {0};
doc_info.pDocName = FileName;
doc_info.pOutputFile = DeviceName;
doc_info.pDatatype="RAW";
DWORD JobId = StartDocPrinter( hPrinter, 1, (LPBYTE)&doc_info );

DWORD error = GetLastError();

// AfxMessageBox(error);

if ( JobId != 0 )
{
DWORD prn_write_error = WritePrinter( hPrinter, (void*)pbuf, dwNumBytes, &written );
DWORD write_error = GetLastError();
if ( written == dwNumBytes )
{
bRet = TRUE;
}
}

EndDocPrinter(hPrinter);
ClosePrinter(hPrinter);
file.Close();
}
return bRet;


When I run this using one printer it works fine. If I switch printers, it doesn't work. There are no errors returned. It successfully opens the printer and StartDocPrinter is successful. When it writes to the printer, no error is return but nothing is sent to the printer. Could this be something with the drivers of the other printer?