What arguments should you provide for the VerQueryValue Windows API call

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

Third and fourth - target buffer and size

What is the second argument, lpSubBlock?

Thanks in advance

+3
source share
2 answers

When you view version information through the resource editor, you may notice that there is an initial section with FILEVERSION, PRODUCTVERISON, etc., and then one or more blocks that 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 VS_FIXEDFILEINFO with detailed information about a non-language, use

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

To find out which languages ​​are supported, use

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

To get detailed information about a specific language version, 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)) 
+3
source

This is a line whose format you can find here:
http://www.hep.wisc.edu/~pinghc/books/apirefeng/v/verqueryvalue.html

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

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

Another article on getting version information:
http://www.microsoft.com/msj/0498/c0498.aspx

+2
source

All Articles