Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi:
When i study the MFC Extension Dll,i encounter some troubles.I can't understand the function of AfxLoadLibrary. Why we use this function,how to use it?If I want to export a class from DLL,what should I do?




Thanks.
Posted

AfxLoadLibrary is for dynamically loading MFC modules based on the name of the DLL or EXE file passed into it. You can read the documentation here.[^]

In order to export a function, you have to use __declspec(dllexport) decoration on the function name, you can follow the tutorials found here[^] to help walk you through it.
 
Share this answer
 
I know what you meaning.Can i use AfxLoadLibrary export a class? If in a project,there are this code : HINSTANCE m_hViewDll = AfxLoadLibrary(_T("*.lib"); if (!m_hViewDll) return;How Can i understand this.It neither export a function nor a class.
 
Share this answer
 
Comments
Ron Beyer 12-Sep-13 22:38pm    
AfxLoadLibrary is for IMPORTING functions. It returns the entry point address to the DLL, so what you wrote above attempts to load a lib file, and if it can't (m_hViewDll == null), it returns. You can't use AfxLoadLibrary to export anything, its for importing a library only.
Member 10066883 12-Sep-13 22:44pm    
you mean AfxLoadLibrary can only import function?
Ron Beyer 12-Sep-13 22:46pm    
Not sure how else to say it, but yes.
Member 10066883 12-Sep-13 22:48pm    
Thank you very much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900