Overview
Dynamic-link libraries (DLLs) lie at the heart of the Microsoft Windows component model—even with the Microsoft .NET common language runtime right around the corner. Windows is itself composed of DLLs, which are binary modules. Binary modularity is different from source code modularity, which is what C++ employs. Instead of programming giant EXEs that you must rebuild and test each time you make a change, you can build smaller DLL modules and test them individually. You can, for example, put a C++ class in a DLL, which might be as small as 12 KB after compiling and linking. Client programs can load and link your DLL very quickly when they run.DLLs have become quite easy to write. Win32 has greatly simplified the programming model, and more and better support is available from the Microsoft Foundation Class (MFC) DLL Wizard and the MFC library. This chapter shows you how to write DLLs in C++ and how to write client programs that use DLLs. We'll explore how Win32 maps DLLs into your processes, and you'll learn the differences between MFC library regular DLLs and MFC library extension DLLs. You'll see examples of simple DLLs of both types as well as a more complex DLL example that implements a custom control.