how to install printer driver

how to install printer driver

Post by Eric W » Sat, 03 Oct 1998 04:00:00



Hi,
    Does any one know how to install a printer driver in win95/nt? I means
after I install the printer driver, then I can see the new installed printer
in "Printer folder?"

    Can anyone tell me what wrong with the following code:

 DRIVER_INFO_2 di2;
 ZeroMemory(&di2, sizeof(DRIVER_INFO_2));
 di2.cVersion = 1000;
 di2.pName  = "TestPrinter";
 di2.pEnvironment= "Windows 95";
 di2.pDriverPath = "c:\\prt\\testprt.drv";
 di2.pDataFile = "c:\\prt\\testprt.drv";
 di2.pConfigFile = "c:\\prt\\testprt.drv";

 if (!AddPrinterDriver("", 2, (LPBYTE)&di2))
 {
  TRACE("Fail to add printer driver - %s\n",
   CUtil::GetLastErrorMsg(GetLastError()));
  return 1;
 }

 // add printer
 PRINTER_INFO_2 pi2;
 ZeroMemory(&pi2, sizeof(PRINTER_INFO_2));
 pi2.pPrinterName= "TestPrinter";
 pi2.pPortName = "FAX:";
 pi2.pDriverName = "TestPrinter";
 pi2.pPrintProcessor = "WinPrint";
 pi2.pDatatype = "RAW";
 HANDLE hPrinter = AddPrinter(szPrinterName, 2, (LPBYTE)&pi2);
 if (hPrinter==NULL)
 {
  TRACE("Fail to add printer - %s\n",
   CUtil::GetLastErrorMsg(GetLastError()));
  return 3;
 }
 ClosePrinter(hPrinter);
--------------------------------------------------------------

    The AddPrinter causes fault in spool32.exe

    Eric

 
 
 

how to install printer driver

Post by swi » Thu, 08 Oct 1998 04:00:00


I'm not very good in device driver development, but i looked up
in my MSDN Library and i found some intresting things to think
about.


Quote:>Hi,
>    Does any one know how to install a printer driver in win95/nt? I means
>after I install the printer driver, then I can see the new installed
printer
>in "Printer folder?"

>    Can anyone tell me what wrong with the following code:

> DRIVER_INFO_2 di2;
> ZeroMemory(&di2, sizeof(DRIVER_INFO_2));
> di2.cVersion = 1000;
> di2.pName  = "TestPrinter";
> di2.pEnvironment= "Windows 95";
> di2.pDriverPath = "c:\\prt\\testprt.drv";
> di2.pDataFile = "c:\\prt\\testprt.drv";
> di2.pConfigFile = "c:\\prt\\testprt.drv";

IMHO It would be wise to copy these files to the system
driver directory (You can obtain this path by calling
GetPrinterDriverDirectory - see MSDN Library) .

Quote:

> if (!AddPrinterDriver("", 2, (LPBYTE)&di2))

MSDN Library says that you should pass NULL if you want to install
a driver on a local machiene

Quote:> {
>  TRACE("Fail to add printer driver - %s\n",
>   CUtil::GetLastErrorMsg(GetLastError()));
>  return 1;
> }

> // add printer
> PRINTER_INFO_2 pi2;
> ZeroMemory(&pi2, sizeof(PRINTER_INFO_2));
> pi2.pPrinterName= "TestPrinter";
> pi2.pPortName = "FAX:";
> pi2.pDriverName = "TestPrinter";
> pi2.pPrintProcessor = "WinPrint";
> pi2.pDatatype = "RAW";
> HANDLE hPrinter = AddPrinter(szPrinterName, 2, (LPBYTE)&pi2);

MSDN Library says that you should pass NULL if you want to install
a printer on a local machiene (same as above). The first parameter
is not then name of your Printer, but a pointer to a server where your
driver should be installed. The name is provided by pPrinterName of
your PRINTER_INFO_2 structure.

Quote:> if (hPrinter==NULL)
> {
>  TRACE("Fail to add printer - %s\n",
>   CUtil::GetLastErrorMsg(GetLastError()));
>  return 3;
> }
> ClosePrinter(hPrinter);
>--------------------------------------------------------------

>    The AddPrinter causes fault in spool32.exe

>    Eric

If this was useful, please be so kind and give me
a short response.


bergfeld.de

 
 
 

how to install printer driver

Post by Eric W » Sat, 10 Oct 1998 04:00:00


Quote:

>> DRIVER_INFO_2 di2;
>> ZeroMemory(&di2, sizeof(DRIVER_INFO_2));
>> di2.cVersion = 1000;
>> di2.pName  = "TestPrinter";
>> di2.pEnvironment= "Windows 95";
>> di2.pDriverPath = "c:\\prt\\testprt.drv";
>> di2.pDataFile = "c:\\prt\\testprt.drv";
>> di2.pConfigFile = "c:\\prt\\testprt.drv";

>IMHO It would be wise to copy these files to the system
>driver directory (You can obtain this path by calling
>GetPrinterDriverDirectory - see MSDN Library) .

>> if (!AddPrinterDriver("", 2, (LPBYTE)&di2))

>MSDN Library says that you should pass NULL if you want to install
>a driver on a local machiene

>> {
>>  TRACE("Fail to add printer driver - %s\n",
>>   CUtil::GetLastErrorMsg(GetLastError()));
>>  return 1;
>> }

>> // add printer
>> PRINTER_INFO_2 pi2;
>> ZeroMemory(&pi2, sizeof(PRINTER_INFO_2));
>> pi2.pPrinterName= "TestPrinter";
>> pi2.pPortName = "FAX:";
>> pi2.pDriverName = "TestPrinter";
>> pi2.pPrintProcessor = "WinPrint";
>> pi2.pDatatype = "RAW";
>> HANDLE hPrinter = AddPrinter(szPrinterName, 2, (LPBYTE)&pi2);

>MSDN Library says that you should pass NULL if you want to install
>a printer on a local machiene (same as above). The first parameter
>is not then name of your Printer, but a pointer to a server where your
>driver should be installed. The name is provided by pPrinterName of
>your PRINTER_INFO_2 structure.

>> if (hPrinter==NULL)
>> {
>>  TRACE("Fail to add printer - %s\n",
>>   CUtil::GetLastErrorMsg(GetLastError()));
>>  return 3;
>> }
>> ClosePrinter(hPrinter);
>>--------------------------------------------------------------

>>    The AddPrinter causes fault in spool32.exe

if I pass the NULL instead of "", the AddPrinter won't cause a fault in
spool32, but instead the function return a error code means the printer
driver is unknown. But the first function AddPrinterDriver succeeds.
Anyway, thanks.

    Eric

 
 
 

how to install printer driver

Post by Eric W » Sat, 10 Oct 1998 04:00:00


By examination of registry, the following code does job well

DRIVER_INFO_2 di2;
ZeroMemory(&di2, sizeof(DRIVER_INFO_2));
di2.cVersion = 1000;
di2.pName  = "TestPrinter";
di2.pEnvironment= "Windows 4.0";    // not Windows 95
di2.pDriverPath = "testprt.drv";
di2.pDataFile = "testprt.drv";
di2.pConfigFile = "testprt.drv";
if (!AddPrinterDriver(NULL, 2, (LPBYTE)&di2))
{
  TRACE("Fail to add printer driver - %s\n",
  CUtil::GetLastErrorMsg(GetLastError()));
  return 1;

Quote:}

// add printer
PRINTER_INFO_2 pi2;
ZeroMemory(&pi2, sizeof(PRINTER_INFO_2));
pi2.pPrinterName= "TestPrinter";
pi2.pPortName = "FAX:";
pi2.pDriverName = "TestPrinter";
pi2.pPrintProcessor = "WinPrint";
pi2.pDatatype = "RAW";
HANDLE hPrinter = AddPrinter(NULL, 2, (LPBYTE)&pi2);

if (hPrinter==NULL)
{
 TRACE("Fail to add printer - %s\n",
 CUtil::GetLastErrorMsg(GetLastError()));
 return 3;

Quote:}

ClosePrinter(hPrinter);

    Eric

 
 
 

1. Installing printer driver (Second try)

I already posted this question long ago but didn't get any answer. I need to
programmatically install printer driver through Add Printer Driver Wizard,
either standard provided by windows 9x/NT/2000 or written by me. Using
standard wizard is preferred. Windows 2000 allows to launch Add Printer
Driver Wizard using rundll32, printui.dll command. However there is no
straightforward way to do so in Windows 9x or NT.

Any help would be really appreciated!

2. Error messages in postscript output

3. Installing Printer Drivers.

4. I NEED HELP.I AM A NEW PC USER.

5. How to install printer driver?

6. CD-Rom Driver

7. Installing Printer Driver automatically

8. Hacked Gforce2 --> Quadro and Pro/E

9. Installing printer driver via WMI fails

10. Windows printer drivers vs. MS-DOS printer drivers

11. Installing a printer miniport driver

12. Need Help on installing a printer driver on the local computer using c++ program

13. Installing a printer driver from a program??