You Can Call a DLL Function from a Printer Driver

Last reviewed: June 16, 1995
Article 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 reference words: 3.10
KBCategory: kbprg kbprint
KBSubcategory: DDKPRNT


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 16, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.