본문 바로가기
VisualStudio.C++.C#/코딩팁,함수활용,단편

VerQueryValue.

by i.got.it 2017. 4. 15.



Retrieves specified 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.

Syntax

C++
BOOL WINAPI VerQueryValue(
  _In_  LPCVOID pBlock,
  _In_  LPCTSTR lpSubBlock,
  _Out_ LPVOID  *lplpBuffer,
  _Out_ PUINT   puLen
);

Parameters

pBlock [in]

Type: LPCVOID

The version-information resource returned by the GetFileVersionInfo function.

lpSubBlock [in]

Type: LPCTSTR

The version-information value to be retrieved. The string must consist of names separated by backslashes (\) and it must have one of the following forms.

\

The root block. The function retrieves a pointer to the VS_FIXEDFILEINFO structure for the version-information resource.

\VarFileInfo\Translation

The translation array in a Var variable information structure—the Value member of this structure. The function retrieves a pointer to this array of language and code page identifiers. An application can use these identifiers to access a language-specific StringTable structure (using the szKey member) in the version-information resource.

\StringFileInfo\lang-codepage\string-name

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]

Type: LPVOID*

When this method returns, contains the address of 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]

Type: PUINT

When this method returns, contains a pointer to the size of the requested data pointed to by lplpBuffer: for version information values, the length in characters of the string stored at lplpBuffer; for translation array values, the size in bytes of the array stored at lplpBuffer; and for root block, the size in bytes of the structure.

Return value

Type: BOOL

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

This function works on 16-, 32-, and 64-bit file images.

The following are predefined version information Unicode strings.

CommentsInternalNameProductName
CompanyNameLegalCopyrightProductVersion
FileDescriptionLegalTrademarksPrivateBuild
FileVersionOriginalFilenameSpecialBuild

 

Examples

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

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

C++
// Structure used to store enumerated languages and code pages.

HRESULT hr;

struct LANGANDCODEPAGE {
  WORD wLanguage;
  WORD wCodePage;
} *lpTranslate;

// Read the list of languages and code pages.

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++ )
{
  hr = StringCchPrintf(SubBlock, 50,
            TEXT("\\StringFileInfo\\%04x%04x\\FileDescription"),
            lpTranslate[i].wLanguage,
            lpTranslate[i].wCodePage);
	if (FAILED(hr))
	{
	// TODO: write error handler.
	}

  // Retrieve file description for language and code page "i". 
  VerQueryValue(pBlock, 
                SubBlock, 
                &lpBuffer, 
                &dwBytes); 
}

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winver.h (include Windows.h)

Library

Mincore.lib

DLL

Api-ms-win-core-version-l1-1-0.dll

Unicode and ANSI names

VerQueryValueW (Unicode) and VerQueryValueA (ANSI)

See also

Reference
GetFileVersionInfo
VarFileInfo
Var
StringFileInfo
StringTable
String
GetFileVersionInfoSize
VS_FIXEDFILEINFO
VS_VERSIONINFO
Conceptual
Version Information



///1287.



'VisualStudio.C++.C# > 코딩팁,함수활용,단편' 카테고리의 다른 글

private . protected . public  (0) 2017.06.22
GetWindowsDirectory.  (0) 2017.04.16
GetFileVersionInfo.  (0) 2017.04.15
Getting the System Version.  (0) 2017.04.15
GetSystemInfo.  (0) 2017.04.15

댓글



 

비트코인




암호화폐       외환/나스닥/골드       암호화폐/외환/나스닥/골드 암호화폐/외환/나스닥/골드   암호화폐/외환/나스닥/골드
     
현물 |선물 인버스 |선물 USDT       전략매니저(카피트레이딩)     롤오버 이자 없는 스왑프리계좌
( 스왑프리 암호화폐도 거래 가능 )    
MT4, MT5 , cTrader 모두 지원     FTMO 계좌 매매운용. MT4,MT5