You Can Call a DLL Function from a Printer Driver

ID: Q131639


The information in this article applies to:
  • Microsoft Windows Device Development Kit (DDK) for Windows, version 3.1


SUMMARY

A printer driver can call other DLL functions if the rules for loading the DLL are followed correctly.


MORE INFORMATION

To have a printer driver call other DLL functions, you need to make sure the functions in the called DLL are using the PASCAL calling convention. For example, the prototype of the DLL function would look similar to this:


   < return type > PASCAL dll_function ( param1, param2,......); 
The DLL can be loaded either explicitly or implicitly. A printer driver can implicitly import DLL functions at link time when the IMPORTS section of the driver's module definition (.DEF) file includes the functions of the called DLL.

It can also use the LoadLibrary function to load the DLL and then use the GetProcAddress function to retrieve the address of the required function. You should check the returned values from LoadLibrary and GetProcAddress to ensure that these functions succeed. If the DLL is not found or does not export the desired function, one of these calls would fail.

A prime example of printer driver calling another DLL is the minidriver, which calls the Microsoft Universal printer driver. The minidriver uses implicit linking (.DEF file); that is, it imports all the functions implicitly at run time.

Additional query words: 3.10

Keywords :
Version : :3.1
Platform :
Issue type :


Last Reviewed: November 1, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.