VerQueryValue

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

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 GetFileVersionInfo function.

  • 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 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 array in a Var variable 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 StringTable structure in the version-information resource.
    \StringFileInfo\lang-codepage\string-name Specifies a value in a language-specific StringTable structure. The lang-codepage name is a concatenation of a language and code page identifier pair found as a DWORD in the translation array for the resource. Here the lang-codepage name must be specified as a hexadecimal string. The string-name name must be one of the predefined strings described in the following Remarks section. The function retrieves a string value specific to the language and code page indicated.
  • 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 *lplpBuffer is freed when the associated pBlock memory is freed.

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

Return Values

If the specified version-information structure exists, and version information is available, the return value is nonzero. If the address of the length buffer is zero, no value is available for the specified version-information name.

If the specified name does not exist or the specified resource is not valid, the return value is zero.

Remarks

The version information functions work only with Win32 file images. They do not work with 16-bit Windows file images.

The following are predefined version information Unicode strings:

Comments InternalName ProductName
CompanyName LegalCopyright ProductVersion
FileDescription LegalTrademarks PrivateBuild
FileVersion OriginalFilename SpecialBuild

Example

The following example shows how to enumerate the available version languages and retrieve the FileDescription string-value for each language.

// 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); 
}

Be sure to call the GetFileVersionInfoSize and GetFileVersionInfo functions before calling VerQueryValue to properly initialize the pBlock buffer.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 3.0 and later Winbase.h    

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

GetFileVersionInfo, GetFileVersionInfoSize, StringTable, Var, VS_FIXEDFILEINFO

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.