Application Dynamically Links to a DLL Using a Class

ID: Q85282


The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) 3.1


SUMMARY

DYNDLL is a file in the Microsoft Software Library that demonstrates using a class, called CDynDLL, to dynamically link to a DLL. The CDynDLL constructor loads the library and retrieves pointers to each function exported by the DLL. The CDynDLL destructor frees the library. The member functions of the CDynDLL class correspond to the functions exported by the DLL.


MORE INFORMATION

The following files are available for download from the Microsoft Download Center. Click the file names below to download the files:

Rdo1test.exe
For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center. The traditional methods an application uses to dynamically link to a dynamic-link library (DLL) in the Windows environment, using the LoadLibrary() and FreeLibrary() functions, can be awkward. The application is required to call GetProcAddress() for each DLL function the application links to, and the application is then required to store the returned address in an array. The source code of the application must also contain a prototype for each called function or the programmer must cast each function parameter to the required type.

The object-oriented techniques of Microsoft C/C++ version 7.0 can be applied to ease the process of dynamically linking with a DLL. An application can define a class that links to the DLL and contains pointers to each of the exported functions. Member functions of the class correspond to the exported functions in the DLL.

Additional query words: softlib DYNDLL.EXE kbfile

Keywords : kbfile kbsample kb16bitonly kbWinOS310
Version : WINDOWS:3.1
Platform : WINDOWS
Issue type : kbinfo


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