🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10346

Problems with VerQueryValue()

#10346
From: JT
Date: Sat, 17 Apr 2004 11:30
43 lines
2215 bytes
I'm trying to read the version info of my DLL using
VerQueryValue() but it always returns a failure.  I
did a few searchs on Google but all the examples I found
fail with the same function.

I confirmed my DLL has version info (right click->Properties).
I am running Win2K and using BCB6 Ent. w/Patch 4.

My Code:

    AnsiString strVersion;
    DWORD dwVerHnd;
    DWORD dwVerInfoSize;
    char FilePath[MAX_PATH];
    strcpy(FilePath, "C:\\MyDLL.dll");

    dwVerInfoSize = ::GetFileVersionInfoSize(FilePath, &dwVerHnd);
    if (dwVerInfoSize)
    {
        char* pVersionInfo = new char[dwVerInfoSize];
        if(pVersionInfo)
        {
            BOOL bRet = ::GetFileVersionInfo(FilePath,
                                             (DWORD)dwVerHnd,
                                             (DWORD)dwVerInfoSize,
                                             (LPVOID)pVersionInfo);
            char* szVer = NULL;
            UINT uVerLength = 100;
            if(bRet)
            {
                bRet = ::VerQueryValue(pVersionInfo,					"\\StringFileInfo\\040904b0\FileVersion",
                         (LPVOID*)&szVer, &uVerLength);

                if (bRet)  // bRet is always zero (Failure from VerQueryValue).
                {
                    strVersion = szVer;
                }
            }
            delete pVersionInfo;
        }
    }
    return strVersion;
Technical Details
Message-ID: <40811567$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,fc037e182c66e00f,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-04-17 04:39:15 PST
From: "JT" <nobody@hotmail.com>
Sender: "JT" <nobody@hotmail.com>
Reply-To: "JT" <nobody@hotmail.com>
Subject: Problems with VerQueryValue()
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 162.27.9.20     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <40811567$1@newsgroups.borland.com>
Date: 17 Apr 2004 04:30:47 -0700
X-Trace: newsgroups.borland.com 1082201447 207.105.83.66 (17 Apr 2004 04:30:47 -0700)
Lines: 43
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail