Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function returns selected version information from the specified version-information resource. To retrieve the appropriate resource, call GetFileVersionInfoSize, and then call GetFileVersionInfo, and then call VerQueryValue.

Syntax

BOOL VerQueryValue(
  const LPVOID 
pBlock,
  LPTSTR 
lpSubBlock,
  LPVOID* 
lplpBuffer,
  PUINT 
puLen
);

Parameters

pBlock

[in] Pointer to the buffer containing the version-information resource returned by the GetFileVersionInfofunction.

lpSubBlock

[in] Pointer to a zero-terminated string specifying which version-information value to retrieve. The string must consist of names separated by backslashes (\) and it must have one of the forms shown in the following table.

Form Description

\

Specifies the root block.

The function retrieves a pointer to the VS_FIXEDFILEINFOstructure for the version-information resource.

\StringFileInfo\lang-codepage\string-name

Specifies a value in a language-specific StringTablestructure.

The lang-codepage name is a concatenation of a language and code page identifier pair found as a DWORDin the translation array for the resource.

Here the lang-codepage name must be specified as a hexadecimal string.

The function retrieves a string value specific to the language and code page indicated.

The string-name name must be one of the following predefined strings:

  • Comments

  • CompanyName

  • FileDescription

  • FileVersion

  • InternalName

  • LegalCopyright

  • LegalTrademarks

  • OriginalFilename

  • ProductName

  • ProductVersion

  • PrivateBuild

  • SpecialBuild

\VarFileInfo\Translation

Specifies the translation array in a Varvariable information structure.

The function retrieves a pointer to an array of language and code page identifiers.

An application can use these identifiers to access a language-specific StringTablestructure in the version-information resource.

lplpBuffer

[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 * lplpBufferis freed when the associated pBlockmemory is freed.

puLen

[out] Pointer to a buffer that receives the length, in characters, of the version-information value.

Return Value

Nonzero indicates that the specified version-information structure exists, and version information is available. If the address of the length buffer is zero, no value is available for the specified version-information name. Zero indicates that the specified name does not exist or the specified resource is not valid.

Remarks

The version information functions are only compatible with 32-bit Windows file images. They are not compatible with 16-bit Windows file images.

The following code sample shows how to enumerate the available version languages and retrieve the FileDescription string-value for each language. Be sure to call the GetFileVersionInfoSizeand GetFileVersionInfofunctions before calling VerQueryValueto properly initialize the pBlockbuffer.

Copy Code
// Structure used to store enumerated languages and code pages.
struct LANGANDCODEPAGE {
  WORD wLanguage;
  WORD wCodePage;
} *lpTranslate;
// Read the list of languages and code pages.
DWORD cbTranslate = 0;
VerQueryValue(pBlock,
   TEXT("\\VarFileInfo\\Translation"),
   (LPVOID*)&lpTranslate,
   &cbTranslate);
// Read the file description for each language and code page.
for( i=0; i < (cbTranslate/sizeof(struct LANGANDCODEPAGE)); i++
)
{
   wsprintf( SubBlock,
   TEXT("\\StringFileInfo\\%04x%04x\\FileDescription"),
   lpTranslate[i].wLanguage,
   lpTranslate[i].wCodePage);
   // Retrieve file description for language and code page "i".
   VerQueryValue(pBlock,
   SubBlock,
   &lpBuffer,
   &dwBytes);
}

Requirements

Header winbase.h
Library coredll.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also