- NSIS Discussion
- printer driver installation
Archive: printer driver installation
hanspaul
10th March 2006 14:00 UTC
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
kichik
10th March 2006 14:04 UTC
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.
hanspaul
10th March 2006 14:14 UTC
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
kichik
10th March 2006 14:27 UTC
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)'
hanspaul
10th March 2006 14:37 UTC
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
kichik
10th March 2006 14:44 UTC
There's a detailed explanation about working with structures with the System plug-in at the bottom of its documentation page.
hanspaul
10th March 2006 14:45 UTC
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
theInstaller
14th March 2006 07:49 UTC
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.
hanspaul
14th March 2006 13:19 UTC
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