Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AddPrinter WIN32 function...

0 views
Skip to first unread message

Jorge quintero

unread,
Nov 21, 2001, 7:49:24 AM11/21/01
to
Hello All,

I am testing a small component that installs printers automatically.
I start by installing the printer driver using AddPrinterDriver
function:

if ( AddPrinterDriver(NULL, 3, (LPBYTE)&driverInfo) ) {
if(verbose){
MessageBox(NULL, _T("print driver added successfully\n"),
PRINTER_NAME, MB_OK);
}
} else {
dwReturn = GetLastError();
displaySystemError(dwReturn);
}
//////////////

And I install my printer. I assign it an available port and call
AddPrinter function:

///////////////
dwReturn = getDefaultPort(portName);
if(portName == NULL){
MessageBox(NULL, _T("Error: Couldn't get an available port"),
PRINTER_NAME, MB_OK|MB_ICONERROR);
return dwReturn;
}

printerInfo.pPortName = TEXT(portName);
printerInfo.pDriverName = DRIVER_NAME;
printerInfo.pPrintProcessor = TEXT("winprint");

#if defined(WINNT4) || defined(WINNT5)
printerInfo.pDatatype = TEXT("NT EMF 1.003");
#else
printerInfo.pDatatype = TEXT("EMF");
#endif //defined(WINNT4) || defined(WINNT5)

printerInfo.Attributes = PRINTER_ATTRIBUTE_LOCAL |
PRINTER_ATTRIBUTE_QUEUED | PRINTER_ATTRIBUTE_ENABLE_BIDI;
printerInfo.pComment = NULL;

// add printer
hPrinter = AddPrinter(NULL, 2, (LPBYTE)&printerInfo);
if (hPrinter){
if(verbose){
MessageBox(NULL, _T("Printer added successfully\n"), PRINTER_NAME,
MB_OK);
}
}
else
{
dwReturn = GetLastError();
displaySystemError(dwReturn);
}


If I use it in my machine, It works fine. But if I try to install a
printer in another machine I always get theeError
ERROR_UNKNOWN_PRINTER_DRIVER

I have enumerated my printer driver and It is present, I have
checked my registry keys and It seems OK to me.

I suppose that if I can install my printer driver, I could install
the printer with no problems, but this is not the case.

Thank you very much for your help.

Jorge Quintero
SRI Grenoble, France.

0 new messages