質問

I've got some code to install a post-script based virtual printer with a port monitor (for printing to PDF). The code works fine on x86 and x64 platforms from WinXP to Win7, unless the PScript5 set of files isn't in the "root" drivers folder. On a few of my test PCs the files were already there, but on a newer Win7 PC I have the files were not already there.

For example, since I know the above is clear as 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\, then my code works. If they aren't, my code fails. The files are always in c:\windows\system32\spool\drivers\w32x86\3\, and the outcome is the same (apparently Windows doesn't look in the "3" sub-folder).

Do I need to copy them from the 3 sub-folder -- is this what others are doing? Doesn't seem like "good practice" for some reason. According to this on MSDN, I can maybe redistribute the files, but I need to contact Microsoft I guess, and I can't figure out how to do that (links are weird, typical).

This is my (cleaned up) code as it runs on Win7 64-bit (32-bit just 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 with error code 2, file not found, if any of the above files are not in the root folder. If I copy the files from the "3" sub-folder and then run the exact code again, it works. I've tried without the APD_COPY_ALL_FILES flag also, same error (2) if files not found, and some other error if they are there (I assume an error code meaning files already exist, shouldn't matter as not related to real issue anyway).

役に立ちましたか?

解決

You don't need to contact Microsoft; you can freely redistribute the PScript5 files. However, to use AddPrinterDriverEx you must ensure that all required files are in the \windows\system32\spool\drivers\w32x86 folder, and you shouldn't assume they'll be in the \windows\system32\spool\drivers\w32x86\3 folder to copy from. You should provide a copy of them with your installer and copy them there yourself before calling AddPrinterDriverEx.

他のヒント

Are you sure you can freely redistribute the pscript5 files?

According to this article from Xeros you must ask to Microsoft to redistribute them:

Other manufacturers such as Xerox can obtain redistribution rights for this file and can then incorporate this DLL with their software applications and print drivers for Microsoft operating systems.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top