Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 21: Tree and List Controls


sprintf(Sentence, "Moment of Inertia: %.3f", MOI);
MessageBox(Sentence);
}


  1. Test the application

  2. Close the dialog box and return to MSVC


22.5 DLL Module-Definition Files...................................................................


22.5.1..Definition File Fundamentals............................................................


We mentioned that a dll must provide a means of importing its functions and making
them available to client applications. We learned above how to help the compiler create
the import library by preceding at least one function with the _declspec(dllexport)
modifier. Microsoft Windows allows another technique. Instead of preceding your
functions with a modifier, you can instead add another object called the Module-
Definition file.

A definition file is a text file that has the extension def. It must contain at least two
sections. The first section is made of one line. It starts with the LIBRARY word followed
by the name of the DLL. It is important that the name you specify be the same name as
the DLL that will be made available to other applications. The second section starts with
the EXPORTS word and contains a list of the functions that will be exported.

In the following exercise, we will create a DLL that can be used to calculate the moment
of inertia using the following illustrations and formulas:
Free download pdf