The ApdFaxDriverInterface Component
Want to handle where fax files are saved, what they are named, or to automatically send a fax? The TApdFaxDriverInterface component is what you need.

First, a little background on the Async Professional Fax printer Driver. This printer driver works like most other printer drivers, it takes the canvas of the printer object and converts it into something the printer can understand. In our case, it converts it into an APF file.

When a document is sent to the printer driver, it looks for an ApdFaxDriverInterface component. If an ApdFaxDriverInterface component is created prior to the start of the print job, that component will receive the printer messages. If the component is not present, an application can be spawned that contains that component.

For 32-bit printer drivers (Microsoft Windows NT/2K/XP) the location and name of the application to spawn is stored in the Registry. If a valid entry is in the Registry, that application is spawned when a document is printed. If no valid entry is found, the APF is saved as C:\DEFAULT.APF. This spawning feature is not completely reliable under the 16-bit printer driver environment due to the way Windows implements 16-bit printer drivers. For this reason, it is best to have the component created prior to the print job in 16-bit environments (which includes Windows 95/98/ME). We will discuss this in just a bit.

The Printer Controller application you write is the front-end for the fax printer driver, which can provide some amazing flexibility and functionality to your faxing operations. The hook into the driver is the ApdFaxDriverInterface component. This component only has 2 properties and 2 events of note. We will look at these events in the sequence in which they are generated as we create a small example.


  1. Create a new project
  2. Drop an ApdFaxDriverInterface component on the form
  3. Drop an ApdComPort and an ApdSendFax component on the form and set their properties for a normal send-fax operation.
  4. Drop an ApdFaxStatus component on the form so you can see what is happening.
  5. Define an ApdFaxDriverInterface.OnDocStart event through the Object Inspector and add the following:
     procedure TForm1.ApdFaxDriverInterfaceDocStart(Sender : TObject);
       ApdFaxDriverInterface1.FileName := 'C:\FAXFILES\OUTFAX.APF';
  6. Define an ApdFaxDriverInterface.OnDocEnd event through the Object Inspector and add the following:
     procedure TForm1.ApdFaxDriverInterfaceDocEnd(Sender : TObject);
       ApdSendFax1.FaxFile := ApdFaxDriverInterface1.FileName;
       ApdSendFax1.PhoneNumber := '260 7151';

Now for the explanations of what we just did. When the printer driver starts the conversion process, the OnDocStart event fires and we set the path and file name of the resulting APF file. Once the printer driver is done converting and saving the file, the OnDocEnd event fires and we fax the file from the event handler for this event.

That is all there is for the Printer Controller application itself. Now we can install this application as the front-end for the printer driver for Windows NT. The Registry keys are predefined in the ApFaxCC.PAS unit, so you will have to include that file in your unitís uses clause. To install the front-end, create a method as shown below. This method can be called in your install application, or as a result of a menu or button click in your distributed application. As an alternative, you can make the changes manually by editing the Registry.

32-bit printer driver (Windows NT/2K/XP):

procedure TForm1.InstallPrinterDriverFrontEnd;
  Reg : TRegistry;
  Reg := TRegistry.Create;
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    Reg.WriteString(IniKey, {Front-end path and file name});

As we mentioned earlier, the application spawning mechanism is not completely reliable in Windows 95/98/ME. For these operating systems, the recommended approach is to have the application running in the background so that it can intercept the print jobs. More than likely you will want your fax application running minimized, hidden, or on the icon tray on the taskbar. The ApdFaxDriverInterface component will be able to intercept all print jobs and your fax application can process the job in any way you want.

The SendFax example project can be modified by dropping an ApdFaxDriverInterface component on it and using the code from the Printer Controller application previously mentioned. The only other changes you could make are to start the application minimized or hidden, then in the OnDocStart event to restore/show the application, if desired.

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.