Microsoft KB Archive/249235

= DOC: AfxLoadLibrary Documentation is not Clear on Usage =

Article ID: 249235

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft Foundation Class Library 4.2
 * Microsoft Visual C++ 4.2 Enterprise Edition
 * Microsoft Visual C++ 5.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 4.2 Professional Edition
 * Microsoft Visual C++ 5.0 Professional Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q249235



SUMMARY
The MSDN documentation for AfxLoadLibrary indicates that you need to use AfxLoadLibrary if your MFC application uses multiple threads; this is not totally correct.



MORE INFORMATION
The only time you need to use AfxLoadLibrary is if you application is multithreaded and you are dynamically loading an MFC extension DLL. To load and unload regular DLLs you can use the Win32 functions LoadLibrary and FreeLibrary. Only when you are loading and unloading MFC extension DLLs in a multithreaded application do you need to use AfxLoadLibrary and AfxFreeLibrary.

If you use AfxLoadLibrary in your application and link statically to MFC then you will get a complier error:

error C2065: 'AfxLoadLibrary' : undeclared identifier

This is because the header file for AfxLoadLibrary, Afxdll_.h, is only included if MFC is linked to the application as a DLL. This is by design because you have to link to the DLL version of MFC to use or create extension DLLs.

Keywords: kbbug kbdll kbdocfix kbpending KB249235

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.