Getting the complete information about DLL/Exe module


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

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


  • Question regarding VC++

    Posted by techieguy22 on 10/09/2010 01:26pm

    Hello, 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..

  • Can't build Dll files

    Posted by Legacy on 03/25/2003 08:00am

    Originally posted by: Millie Mak

    I can create a DLL in Borland C++ but I cant seem to access it from another program

  • how to export vb function through c+++ dll

    Posted by Legacy on 08/23/2002 07:00am

    Originally posted by: sliba

    hi friends,
    how to invoke vb dll through c++ dll.
    thanks in advance.

  • This code cannot work

    Posted by Legacy on 11/24/2000 08:00am

    Originally 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:
    [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

  • Access to Dialogs in the Application From an Extension DLL

    Posted by Legacy on 04/23/2000 07:00am

    Originally 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.

  • How I can know the dependency of a module DLL ?

    Posted by Legacy on 03/21/2000 08:00am

    Originally 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

  • how to get the detail information of the functions in DLL?

    Posted by Legacy on 10/14/1999 07:00am

    Originally 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
    i 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 08:00am

    Originally posted by: Riku

    if load module, such as worked now display driver, system (and Windows NT, really) HANG !

  • No need to call LoadLibrary

    Posted by Legacy on 01/20/1999 08:00am

    Originally posted by: Brad Bruce

    There is no need to call LoadLibrary when retrieving version information.  
    1. The functions that retrieve version information use the file name.
    2. There may be dependencies in the DLL that you attempt to load that are not in the current directory.

    The following is a rewrite of the function GetInfo:

    bool CLibraryInfo::GetInfo()
    DWORD length;
    DWORD nullHandle;
    TCHAR fileName [MAX_PATH];
    LPVOID versionPtr;
    UINT verLength;

    // Determine whether the operating system can obtain version information
    // about the file. If version information is available, GetFileVersionInfoSize
    // returns the size in bytes of that information.
    // As with other file installation functions, GetFileVersionInfo works only
    // with Win32 file images. It does not work with 16-bit Windows file images.

    // Its is neccessary to call this function before calling GetFileVersionInfo.

    if (m_DllInfo.stDllName.IsEmpty ())
    return (false);

    strcpy(fileName, m_DllInfo.stDllName);
    length = ::GetFileVersionInfoSize (fileName, &nullHandle);

    if (length <= 0)
    return (false);

    // Now call the GetFileVersionInfo function to version information
    // First initialize the member variable to recieve the information.

    m_pVersionInfo = new BYTE [length];

    if (!::GetFileVersionInfo (fileName, NULL, length, m_pVersionInfo))
    return (false);

    // The Win32 API contains the following predefined version information
    // strings.
    // CompanyName, FileDescription, FileVersion, InternalName, LegalCopyright,
    // OriginalFilename ProductName ProductVersion

    if (!::VerQueryValue (m_pVersionInfo, _T ("\\"), &versionPtr, &verLength))
    return (false);

    m_FixedFileInfo = *(VS_FIXEDFILEINFO*)versionPtr;

    if (!GetDynamicInfo ())
    return (false);

    // Get the information which is fixed for the module.

    if (!GetFixedFileInfo ())
    return (false);

    // Set the infoObtained flag to true.

    m_bInfoObtained = true;

    return (true);

  • AfxLoadLibrary

    Posted by Legacy on 01/19/1999 08:00am

    Originally 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().

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date