VerQueryValue

3.1

  #include <ver.h>    

  BOOL VerQueryValue(lpvBlock, lpszSubBlock, lplpBuffer, lpcb)    
  const void FAR* lpvBlock; /* address of buffer for version resource */
  LPCSTR lpszSubBlock; /* address of value to retrieve */
  VOID FAR* FAR* lplpBuffer; /* address of buffer for version pointer */
  UINT FAR* lpcb; /* address of buffer for version-value length */

The VerQueryValue function returns selected version information from the specified version-information resource. To obtain the appropriate resource, the GetFileVersionInfo function must be called before VerQueryValue.

Parameters

lpvBlock

Points to the buffer containing the version-information resource returned by the GetFileVersionInfo function.

lpszSubBlock

Points to a zero-terminated string specifying which version-information value to retrieve. The string consists of names separated by backslashes (\) and can have one of the following forms:

Form Description

\ Specifies the root block. The function retrieves a pointer to the VS_FIXEDFILEINFO structure for the version-information resource.
\VarFileInfo\Translation Specifies the translation table in the variable information block. The function retrieves a pointer to an array of language and character-set identifiers. An application uses these identifiers to create the name of an language-specific block in the version-information resource.
\StringFileInfo\lang-charset\string-name Specifies a value in a language-specific block. The lang-charset name is a concatenation of a language and character-set identifier pair found in the translation table for the resource. The lang-charset name must be specified as a hexadecimal string. The string-name name is one of the predefined strings described in the following Comments section.

lplpBuffer

Points to a buffer that receives a pointer to the version-information value.

lpcb

Points to a buffer that receives the length, in bytes, of the version-information value.

Return Value

The return value is nonzero if the specified block exists and version information
is available. If lpcb is zero, no value is available for the specified version-information name. The return value is zero if the specified name does not
exist or the resource pointed to by lpvBlock is not valid.

Comments

The string-name in the lpszSubBlock parameter can be one of the following predefined names:

Name Value

Comments Specifies additional information that should be displayed for diagnostic purposes.
CompanyName Specifies the company that produced the file—for example, “Microsoft Corporation” or “Standard Microsystems Corporation, Inc.”. This string is required.
FileDescription Specifies a file description to be presented to users. This string may be displayed in a list box when the user is choosing files to install—for example, “Keyboard Driver for AT-Style Keyboards” or “Microsoft Word for Windows”. This string is required.
FileVersion Specifies the version number of the file—for example, “3.10” or “5.00.RC2”. This string is required.
InternalName Specifies the internal name of the file, if one exists—for example, a module name if the file is a dynamic-link library. If the file has no internal name, this string should be the original filename, without extension. This string is required.
LegalCopyright Specifies all copyright notices that apply to the file. This should include the full text of all notices, legal symbols, copyright dates, and so on—for example, “Copyright Microsoft Corporation 1990–1991”. This string is optional.
LegalTrademarks Specifies all trademarks and registered trademarks that apply to the file. This should include the full text of all notices, legal symbols, trademark numbers, and so on—for example, “Windows(TM) is a trademark of Microsoft Corporation”. This string is optional.
OriginalFilename Specifies the original name of the file, not including a path. This information enables an application to determine whether a file has been renamed by a user. The format of the name depends on the file system for which the file was created. This string is required.
PrivateBuild Specifies information about a private version of the file—for example, “Built by TESTER1 on \TESTBED”. This string should be present only if the VS_FF_PRIVATEBUILD flag is set in the dwFileFlags member of the VS_FIXEDFILEINFO structure of the root block.
ProductName Specifies the name of the product with which the file is distributed—for example, “Microsoft Windows”. This string is required.
ProductVersion Specifies the version of the product with which the file is distributed—for example, “3.10” or “5.00.RC2”. This string is required.
SpecialBuild Specifies how this version of the file differs from the standard version—for example, “Private build for TESTER1 solving mouse problems on M250 and M250E computers”. This string should be present only if the VS_FF_SPECIALBUILD flag is set in the dwFileFlags member of the VS_FIXEDFILEINFO structure in the root block.

Example

The following example loads the version information for a dynamic-link library and retrieves the company name:

BYTE   abData[512];
DWORD  handle;
DWORD  dwSize;
LPBYTE lpBuffer;
char   szName[512];

dwSize = GetFileVersionInfoSize("c:\\dll\\sample.dll", &handle));

GetFileVersionInfo("c:\\dll\\sample.dll", handle, dwSize, abData));

VerQueryValue(abData, "\\VarFileInfo\\Translation", &lpBuffer, &dwSize));

if (dwSize!=0) {
    wsprintf(szName, "\\StringFileInfo\\%8lx\\CompanyName", &lpBuffer);
    VerQueryValue(abData, szName, &lpBuffer, &dwSize);
}

See Also

GetFileVersionInfo