Rebuilding the Async Pro Printer Drivers


Async Professional includes printer drivers for Windows 95/98, ME, NT 4.0, 2000, and XP.  Usually, the printer drivers that we ship do everything that you need, but occasionally you might want to add functionality that requires rebuilding the printer drivers.  Some of the bigger reasons for wanting to rebuild the printer drivers are when you need to support international versions of Windows NT (primarily the Far East versions), want to change the default properties of the printer, want to add/remove properties (such as page sizes), or want to change the names of the printers.


Fax Printer Drivers 101: The Basics

Before we go into the details of rebuilding the printer drivers, let’s talk a bit about what the printer drivers are and how they work.  The Windows printer subsystem was designed to provide a ‘universal’ interface for all Windows applications for access to the physical printers.   Under Windows 3.1x, Windows 95 and Windows 98, the printer subsystem is 16-bit only.  Our printer driver (APFGEN.DRV) uses the standard UNIDRV.DLL that comes with Windows to handle most of the printer functions.  When the application prints the document, it sends raster data to UNIDRV.DLL, which we take and use to create a fax file.  Under NT, the printer subsystem is 32-bit.  Our printer driver is divided into three files, and uses the RASDD supporting files supplied with Windows.  The NT printer driver consists of a mini-driver (APFPDENT.DLL), port monitor stubs (APFMON35.DLL for NT 3.51, APFMON40.DLL for NT 4), and the port monitor (APFAXCNV.DLL). Basically the same thing happens when a document is printed, except everything goes through RASDD.DLL instead of UNIDRV.DLL.


Fax Printer Drivers 201: Rebuilding the 16-bit printer driver

The 16-bit printer driver is used for Windows 3.1x, Windows 95 and Windows 98.  The source file for the printer driver is APFGEN.DRV, which should be in your AsyncPro\PrnDrv\Win95_3x folder.  Since it is a 16-bit driver, Delphi 1 must be used to compile it.  The APFGEN.DPR source just defines how the printer driver behaves (accepting raster data and converting it using a scaled down version of the ApdFaxConverter).  To make the scaled down version of the ApdFaxUnpacker, you’ll need to include the ‘PRNDRV’ compiler definition to the project (if you forget to do it, you’ll get a compiler error message).  The properties of the printer (paper sizes, resolution flags, etc) are maintained in the APFGEN.RC, APFGEN.RES and APFGEN.GPC files.  To edit those files, you will need UNITOOL.EXE.  UNITOOL is part of the Windows DDK (Device Driver Kit), which you can get through MSDN. 

Rebuilding the 16-bit driver is a piece of cake.  Make the changes you need with UNITOOL, make the changes you need to APFGEN.DPR source, then compile APFGEN.DPR in Delphi 1.  The resulting file will be named APFGEN.DLL, rename it to APFGEN.DRV and install it.  That’s all there is to it.


Fax Printer Drivers 301: Rebuilding the NT printer driver

If rebuilding the 16-bit drivers was like a walk in the park, rebuilding the NT printer driver is like crawling through a swamp with alligators biting at your heels.  Since there are three parts to the NT driver, let’s take each one separately.

The port monitor (APFAXCNV.DLL): This part is what handles converting the data from the spooler into a fax file, and what interfaces with the ApdFaxDriverInterface component. This is the only part of the NT printer drivers that can be touched with Delphi.  The other parts operate at the Kernel level, something that Delphi can’t do very well, so they are built using Visual C++ and the Windows DDK.  The source for the port monitor is in the AsyncPro\PrnDrv\NTCommon folder.  Any 32-bit version of Delphi can be used to compile this DLL.  Just make whatever changes you need, compile it and install it.

The port monitor stub (APFMON40.DLL): This part is the interface to the Printer properties dialog, and calls the port monitor to do the actual data conversion.  To rebuild this DLL, copy the \Mon folder (from the AsyncPro\PrnDrv\NT4 folder for NT4 or AsyncPro\PrnDrv\NT351 for NT 3.51) to the DDK’s DDK\Src\Print folder and do a Build with the DDK.

The mini-driver (APFPDENT.DLL): This part determines the capabilities of the printer, such as page sizes, the properties dialog, and other such things.  Rebuilding the mini-driver is where things can get messy rather quickly.  The UNITOOL utility from the DDK is used to modify the capabilities of the printer.  But, UNITOOL will create a 16-bit resource that can’t be used by the 32-bit mini-driver; it needs to be converted first.  Start UNITOOL and open the 16-bit resource that we supply in the AsyncPro\PrnDrv\NT4\MiniDrv\16 folder.  Make any changes you require in UNITOOL and save the resource in the AsyncPro\PrnDrv\NT4\MiniDrv folder.  Close UNITOOL and open APFPDENT.RC from the MiniDrv folder with a text editor (such as Notepad).  Since the resource is in a 16-format, we’ll need to make a few changes here. The first thing to change is the operating system flag.  Find this line:


#define VOS_DOS_WINDOWS16       0x00010001L

and replace it with:


#define VOS_NT_WINDOWS32        0x00040004L


Now, find this line:



and replace it with:




Finally, find these lines:




and replace them with these:





Save the APFPDENT.RC file and exit the text editor.  Now, copy the MiniDrv folder (without the \16 folder) to the DDK\Src\Print\Mini folder.  Start a DOS window and set the DDK environment according to the DDK instructions (there is usually a shortcut in the Program files | DDK menu called “Free build environment” that will do it for you).  Now, refresh the resources by running the NTGPCEDT program from the DOS prompt and loading the APFPDENT.RC file that you copied to the DDK tree.  There isn’t anything to configure there, so just close it.  If the supporting resources needed to be refreshed, NTGPCEDT will display a message asking if you want to save NT.GPC; if you get the dialog choose Yes.

Now, we get to set up the build paths.  Open the DIRS file in DDK\Src\Print\Mini, add the MiniDrv folder to the list, and save DIRS.  That tells the Build utility that you want to compile whatever it finds in the MiniDrv folder.  Now, we get to actually build the driver.  Enter ‘BUILD’ at the DOS prompt, and sit back and wait.  The build process can take anywhere from 5 minutes to an hour (hint: you can modify the DIRS file through the DDK’s tree to limit the directories that BUILD will look in).  When everything is done and the smoke has cleared, your new mini-driver should be in the DDK\Lib\i386\Free folder.  Once you install it, whatever changes you have made should show up in the Printer Properties dialog.


Fax Printer Drivers 401: Installing the printer drivers

What good is a newly compiled printer driver if you don’t install it?  You can either install the complete printer driver by copying the changed driver files to the appropriate Windows folder manually, or you can reinstall all of the printer driver files.


Replacing the printer driver files manually:

This will only work if the printer driver is already installed on the system.  For the 16-bit drivers, copy the APFGEN.DRV file to the Windows\System folder.  If our printer driver has already been used since the system was started, you may get a message saying the file couldn’t be copied because the destination file is in use.  If you get that message, you’ll have to reboot to replace the driver.  For NT, it is a bit more complicated.  You need to shut down the spooler service, and then copy the new files to the appropriate folder.  APFPDENT.DLL should go in the Windows\System32\Spool\Drivers\w32X86 folder; APFMONXX.DLL and APFAXCNV.DLL should go in the Windows\System32 folder.  Once everything has been copied, start the spooler service up again.  If you get messages while copying that the destination is still in use, you will have to reboot.


Installing the printer driver files programmatically:

The easiest way to install the fax printer drivers is to do it programmatically, using something like the PInst example project.  Copy the required printer driver files (APFMON40.DLL, APFAXCNV.DLL, and APFPDENT.DLL for NT4; just APFGEN.DRV for the 16-bit drivers) to an empty directory or floppy disk, then copy your PInst derivative to that folder. The code in PInst will detect what version of the printer driver to install, then will install it for you.

Installing the printer driver files through the Add Printer wizard:

If PInst fails for some reason, or if you don’t want to install the printer driver programmatically, you can still install the printer drivers through the Add Printer Wizard.  Copy the required printer driver files to an empty folder or a floppy disk, just like you did in the previous step.  You will also need to copy the INF files for the operating systems.  The NT INF files are in the AsyncPro\PrnDrv\NT4\INF folder; the Windows 95/98 INF file is on our FTP ( site (and on your TurboPower Product Suite CD) in the Pub\Apro\Demos folder.  Open up the Control Panel | Printers applet, and double-click the Add Printer icon.  When it asks for the name of the printer, click the ‘Have disk’ button and navigate to the disk or folder where you have copied driver files and select that folder. Our fax printer driver will be installed just like a regular paper printer is installed.

This site is not affiliated, endorsed, or otherwise associated with the entity formerly known as TurboPower Software. The owners and maintainers of were merely meager employees of the aforementioned organization, providing this site out of the pure goodness of their collective hearts. Logo

Last updated: July 22, 2003.