Getting the complete information about DLL/Exe module | CodeGuru

Getting the complete information about DLL/Exe module

Environment: VC++ 6.0 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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Jan 15, 1999
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Environment: VC++ 6.0

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.

Download demo project – 24 KB

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.