wdk - AddPrinterDriverEx fails if pscript5.dll not in root drivers folder -
i've got code install post-script based virtual printer port monitor (for printing pdf). code works fine on x86 , x64 platforms winxp win7, unless pscript5 set of files isn't in "root" drivers folder. on few of test pcs files there, on newer win7 pc have files not there.
for example, since know above clear mud, on windows xp 32-bit, if these files:
ps5ui.dll pscript5.dll pscript.hlp pscript.ntf
are located in c:\windows\system32\spool\drivers\w32x86\, code works. if aren't, code fails. files in c:\windows\system32\spool\drivers\w32x86\3\, , outcome same (apparently windows doesn't in "3" sub-folder).
do need copy them 3 sub-folder -- others doing? doesn't seem "good practice" reason. according this on msdn, can maybe redistribute files, need contact microsoft guess, , can't figure out how (links weird, typical).
this (cleaned up) code runs on win7 64-bit (32-bit uses "windows nt x86" instead of "windows x64"):
driver_info_3 di; memset(&di,0,sizeof(di)); di.cversion = 3; di.pname = "my pdf printer"; di.penvironment = "windows x64"; di.pdriverpath = "pscript5.dll"; di.pdatafile = "mypdf.ppd"; di.pconfigfile = "ps5ui.dll"; di.phelpfile = "pscript.hlp"; di.pdependentfiles = "pscript.ntf\0\0"; di.pmonitorname = null; di.pdefaultdatatype = "raw"; if(!addprinterdriverex(null,3,(byte*)&di,apd_copy_all_files|apd_install_warned_driver)) { char err[1024]; sprintf(err,"error adding printer driver: 0x%08x",getlasterror()); prompt(err); return; }
addprinterdriverex fails error code 2, file not found, if of above files not in root folder. if copy files "3" sub-folder , run exact code again, works. i've tried without apd_copy_all_files flag also, same error (2) if files not found, , other error if there (i assume error code meaning files exist, shouldn't matter not related real issue anyway).
you don't need contact microsoft; can freely redistribute pscript5 files. however, use addprinterdriverex
must ensure required files in \windows\system32\spool\drivers\w32x86
folder, , shouldn't assume they'll in \windows\system32\spool\drivers\w32x86\3
folder copy from. should provide copy of them installer , copy them there before calling addprinterdriverex
.
Comments
Post a Comment