Back to Amir Israeli Homepage

[CLibraryFuncExtractor : Extract functions from DLL's ]

This article was contributed by Amir Israeli Amir Israeli.
Amir Israeli Web Site

Environment: Win 95/98 VC6 SP4

The class is derived and uses the functionality within CLoadLibrary

3 types of constructors are found: all send given parameters to base class. (do read this class and documenrtation Here)

	CLibraryFuncExtractor() : CLoadLibrary() { }
	// 2 constructors calling base constructor
	CLibraryFuncExtractor(LPCTSTR lpszFileName) : CLoadLibrary(lpszFileName) { }
	CLibraryFuncExtractor(LPCTSTR lpszFileName,BOOL bSystemDirectory,BOOL bWindowsDirectory) 
		: CLoadLibrary(lpszFileName,bSystemDirectory,bWindowsDirectory) { }
The class allows you to insert multiple number of functions in 1 step , or a single function one by one. To use that first : load the library you want then extract functions :
// loading library of MAPI : I want to extract 12 functions to use
// simple MAPI to send mail ,recieve , view (Simple MAPI is a small part of MAPI 
BOOL bLoaded = Load(_T("Mapi32.dll"),FALSE,TRUE);
if (bLoaded) {
	LPCTSTR *pFunctions = {
		_T("MAPIAddress") ,_T("MapiDeleteMail")
	int nFound = Add(12,pFunctions);
	if (nFound==12)
	{	// all functions were found : therefore OK!

	else // not all functions were found


Here are function declerations:
	int Add(int nCount,LPCTSTR *lpszProcName);
	BOOL AddProc(LPCTSTR lpszProcName,BOOL bRefreshAddress=FALSE);
You get function address by calling : GetProc() . Addresses the were already found are stored in a template based array , so needn't look again within the library on every time you need address. If the function doesnt already exist in array it is being looked for in the library.
FARPROC GetProc(LPCTSTR lpszProcName,BOOL bLookUpIfNotInMap=TRUE);
Beware : when library is unloaded You must assume that addresses of functions are INVALID (though the library doesn't always unload on this call) during the lifetime of application the virtual address of library is Locked therfore you can always use library-function-addresses

Here are 2 screens of available project : The 2 screens display the library path that was selected (on top) , When a function is selected from the combobox , its' name and address are displayed within the 2 static controls on bottom.


Download demo project - 38 Kb
Download source - 3 Kb


Date Posted: December 20, 2000

Home  |  Links  |  About

Make your own free website on