Archive: printer driver installation


printer driver installation
Hello,

could someone post me an example on how I would install a printer with NSIS? I expierence to use the necessery functions in NSIS: GetPrinterDriverDirectory, AddPrinter and AddPrinterDriver.

a c++ Way for GetPrinterDriverDirectory would be:

char *pDirInfo = NULL;
DWORD cbBuf = 0;
DWORD pcbNeeded;
GetPrinterDriverDirectory(NULL,NULL,1,(LPBYTE)pDirInfo,0,&pcbNeeded);
pDirInfo = new char[1+pcbNeeded/sizeof(char)+50];
cbBuf = sizeof(char)*(1+pcbNeeded/sizeof(char)+50);


GetPrinterDriverDirectory(NULL,NULL,1,(LPBYTE)pDirInfo,cbBuf,&pcbNeeded);


thanks a lot for help

hans


You can write a plug-in that'd call those API functions, or you can call them from the script using the System plug-in.


yes this is actually what I tried, but I don't know how I actually call it correctly.

System::Call 'winspool.drv::GetPrinterDriverDirectory(0,0,i 1, t .r1, i ${NSIS_MAX_STRLEN,i ${NSIS_MAX_STRLEN)'

for example won't work for me :(

so my questions does someone have NSIS examples on how to use GetPrinterDriverDirectory, AddPrinterDriver and AddPrinter?

thanks a lot

hans


There are a few errors in that System call. You didn't specify a type for the first two arguments and you forgot to close both NSIS_MAX_STRLEN uses. You also set the wrong type for the last argument. It should be a pointer to an integer, not an integer. The call should be:

System::Call 'winspool.drv::GetPrinterDriverDirectory(i 0, i 0, i 1, t .r1, i ${NSIS_MAX_STRLEN}, *i)'

thanks a lot, it worked perfect, my last problem, I am still stuck with these data-types. DRIVER_INFO_4
would you be so kind to please tell me how I could perform something like that with NSIS?:

DRIVER_INFO_4 DriverInfo;
// fill the memory with zeros
memset(&DriverInfo, 0, sizeof(DriverInfo));

// default info
DriverInfo.cVersion = 3;
DriverInfo.pName = "my printer";

etc....

AddPrinterDriver(NULL, 2, (BYTE*)&DriverInfo);


thanks very much

hans


There's a detailed explanation about working with structures with the System plug-in at the bottom of its documentation page.


ok I will read into it, I was searching inside the forum but could not find anything. Thanks a lot for the link and the example above, kichik.

greetings
hans


a option
maybe you could need that?

try this command in the shell

rundll32 printui.dll,PrintUIEntry /?

as example you can use the full command
rundll32 printui.dll,PrintUIEntry /in /n \\printserver\DeskJet /q
to install a printer.

So you can easy add and remove network printers.


yea but the prob is that this method doesn't allow you to add a custom printer with a custom printer driver. I finally decided to keep the code in c++ and just call the dll externally from nsis.

thanks for all your replies,

hans