简体   繁体   中英

What Arguments are you supposed to give to the Windows API call VerQueryValue

I understand the first argument must be the result of GetFileVersionInfo().

The third and forth are target buffer and size

What is the second argument, lpSubBlock?

Thanks In Advance

When you view the version info through the resource editor you might notice that there is an initial section with FILEVERSION, PRODUCTVERISON etc. and then one or more blocks which contain language specific settings.

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 5,0,0,0
 PRODUCTVERSION 5,0,0,0
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x40004L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "CompanyName", ""
            VALUE "FileVersion", "5, 0, 0, 0"
            VALUE "ProductName", ""
            VALUE "ProductVersion", "5, 0, 0, 0"
        END
        BLOCK "000004b0"
        BEGIN
            VALUE "CompanyName", ""
            VALUE "FileVersion", "5, 0, 0, 0"
            VALUE "ProductName", ""
            VALUE "ProductVersion", "5, 0, 0, 0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x0, 1200, 0x409, 1200
    END
END

To get a VS_FIXEDFILEINFO with the non language specific detail use

VS_FIXEDFILEINFO *versionInfo;
PUINT versionInfoSize;
VerQueryValue(buffer.get(), TEXT("\\"), (void**) &versionInfo, &versionInfoSize))

To find out what languages are supported use

Var *translationsInfo;
PUINT transaltionInfoSize;
VerQueryValue(buffer.get(), TEXT("\\VarFileInfo\\Translation"), (void**) &translationsInfo, &transaltionInfoSize))

To get the language specific version detail then use

StringTable *stringTable;
PUINT stringTableSize;
std::wstring path( L"\\StringFileInfo\\" );
path += L"040904b0";  // get this value from the language support list
path += L"\\FileVersion";
VerQueryValue(buffer.get(), path.c_str(), (void**) &stringTable, &stringTableSize))

It must be a string whose format you can find here:
http://www.hep.wisc.edu/~pinghc/books/apirefeng/v/verqueryvalue.html

There is another example of usage (in VB, easy to read):
http://support.microsoft.com/kb/160042

You can also check out this whole CodeProject article for a working example in C++:
http://www.codeproject.com/KB/cpp/GetLocalVersionInfos.aspx

Another article on the subject of retrieving version information:
http://www.microsoft.com/msj/0498/c0498.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM