hi. I have an MFC based app which uses a printer to print.
After install printer named "HP Lazer Jet 4000 PCL 6".
When I print it with "Test Page", the page can be printed out successfully( or by other program such as word 2000 ). So I think
the printer is installed properly.
But In my app I will use this printer to print pages.
CDC * CreatePrinterDC( LPCTSTR lpszPrinter )
HANDLE hPrinter = NULL ;
if (!OpenPrinter((LPTSTR)lpszPrinter , &hPrinter, NULL))
DWORD dwErr = GetLastError() ; // dwErr == 0
// A zero for last param returns the size of buffer needed.
// Get the printer settings and reset with default values.
int nSize = DocumentProperties(NULL, hPrinter, (LPTSTR)
lpszPrinter , NULL, NULL, 0);
dwErr = GetLastError() ; // dwErr == 6
if(nSize < 0)
ClosePrinter( hPrinter ) ;
// other codes for set the default behaviors for this
// printer and return the printer DC.
From MSDN, "6" means the handle is Invalid, But the function call
I don't the reason. who has ideas ?
Waiting OFFERS from CMU, UMass, UC Davis, OSU Mail to me