Getting the complete information about DLL/Exe module
There have been couple of articles which have discussed about how to get file version info from resource file and getting to know the version of common control DLL installed on your machine. This article also falls under the same category but with a slight modification.
Like pervious articles, I am also using the same API function ::GetFileVersionInfo. But this function doesnt work if the DLL/Exe module is not mapped into the current processs memory space. To make this function work it becomes very important that the module should be brought into the memory space of process.
I have tried to build a wrapper class to get complete information about a DLL/Exe module. The class name ClibraryInfo may not sound very appropriate but some reasons I couldnt help it. The class has accessor functions for individual piece of information about module. But each function makes it sure that the protected member functions, which implement the API calls, are not executed time and again. I have tried to encapsulate complete information in a data structure DLLINFO. If you dont want to call each accessor function to get individual function, I have tried to put one function which returns the information in the DLLINFO data structure and then you can deal with individual member variables of the structure. You may feel that class has some unwanted function calls, but the kind of application I was doing I had to write these functions.
The following piece of code gets the module handle for DLL/Exe for which information is sought. If first call fails, I am assuming that module is not mapped in the processs memory. I have loaded the module explicitly in the process. If that also fails, then failure is reported. But it has been made sure that if the module was explicitly loaded, it is freed before the process terminates.
hModule = ::GetModuleHandle (m_DllInfo.stDllName);
if (hModule == NULL) {
// the dll/module may not be mapped into our space. So try to load the module
hModule = (HMODULE)LoadLibrary (m_DllInfo.stDllName);
if (hModule == NULL) {
return (false);
}
m_bLibLoaded = true;
}
This project has been compiled on Windows 95 using VC ++ 6 compiler. If you try to open this project on previous version of VC, you will get couple warnings related to debug flags set by VC++ 6 compiler. And it is very important that for project to compile, VERSION.LIB has been included in the link/compile settings.

Comments
Question regarding VC++
Posted by techieguy22 on 10/09/2010 06:26amHello, this is one of the most complete info I've read about DLL so far. I'm about to try it but you said it won't work well with previous version of VC. But how can I be able to determine my VC++ compiler version?? I know that you need to type something in the command prompt to find out and I forgot the command. and also, how can I tell if it's 32 or 64 bit, as naveen mentioned? thanks..
ReplyCan't build Dll files
Posted by Legacy on 03/25/2003 12:00amOriginally posted by: Millie Mak
I can create a DLL in Borland C++ but I cant seem to access it from another program
Replyhow to export vb function through c+++ dll
Posted by Legacy on 08/23/2002 12:00amOriginally posted by: sliba
hi friends,
Replyhow to invoke vb dll through c++ dll.
thanks in advance.
This code cannot work
Posted by Legacy on 11/24/2000 12:00amOriginally posted by: Martin Erdrich
You are using the address of a CString object as an Argument
to the fourth parameter:
::VerQueryValue (m_pVersionInfo, (LPTSTR)(LPCTSTR)query, (LPVOID*)&m_DllInfo.stCopyRight,&verLength);
The API Documentation reads:
lplpBuffer
[out] Pointer to a variable that receives a pointer to the requested version information in the buffer pointed to by pBlock. The memory pointed to by *lplpBuffer is freed when the associated pBlock memory is freed.
That means a pointer to an internal buffer is returned. I wonder if you've ever tried this in debug/release builds,
because you are overwriting the first 4 Bytes of the CString
object
ReplyAccess to Dialogs in the Application From an Extension DLL
Posted by Legacy on 04/23/2000 12:00amOriginally posted by: R. Radha
I have one MDI application which has multiple views. I am going to seperate one view from my application along with its document and create an extension DLL.
In that document which is seperated from the application, some functions are accessing the member functions which are in the application class. Some functions call domodal of dialogs which are in the application. These functions and dialogs are common for other views. So i could not take these functions out from the application.
How to access the member functions and dialogs which are in inside the application from an extension dLL?
Please give your suggesstions at the earliest possible.
ReplyHow I can know the dependency of a module DLL ?
Posted by Legacy on 03/21/2000 12:00amOriginally posted by: NYu
I had downloaded a sample program (ADOSAMPLE)which use the MSADO10.DLL. But I can not registe the MSADO10.DLL in my system Windows NT 4.0 (WorkStation with service pack 5). It seem private some modules used by the MSADO10.DLL.
My question:
How I can find the dependency modules for a DLL module ? There is some tools to do it ?
Thank very much
M. NYu
Replyhow to get the detail information of the functions in DLL?
Posted by Legacy on 10/14/1999 12:00amOriginally posted by: hammer zhang
Quike view can get the function name in dll , but how can i invoke a function without knowing its parameter . so
Replyi wonder if there is some method or tool to get the parameter information from DLL file . If there is , how to
do or which tool shall i use?
Don't need to load module, becouse system (and Windows NT) is hang !
Posted by Legacy on 02/15/1999 12:00amOriginally posted by: Riku
Reply
No need to call LoadLibrary
Posted by Legacy on 01/20/1999 12:00amOriginally posted by: Brad Bruce
ReplyAfxLoadLibrary
Posted by Legacy on 01/19/1999 12:00amOriginally posted by: Jay Nelson
In order to load a DLL dynamically in a Win32 app, you have two choices:
1. The SDK library function - ::LoadLibrary()
2. If using MFC - ::AfxLoadLibrary()
If you are using a mutli-threaded app, call ::AfxLoadLibrary() instead
of ::LoadLibrary().
Reply