Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 42 additions & 30 deletions sdk-api-src/content/winver/nf-winver-verqueryvaluea.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,48 +154,60 @@ Be sure to call the <a href="/windows/desktop/api/winver/nf-winver-getfileversio


```cpp

// Structure used to store enumerated languages and code pages.
typedef struct {
WORD wLanguage;
WORD wCodePage;
} LANGANDCODEPAGE;

LANGANDCODEPAGE *lpTranslations;
UINT cbTranslations;
HRESULT hr;

struct LANGANDCODEPAGE {
WORD wLanguage;
WORD wCodePage;
} *lpTranslate;
BOOL exists;
TCHAR *lpBuffer;
DWORD dwBytes;
TCHAR SubBlock[50];

// 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++ )
exists = VerQueryValue(
pBlock,
TEXT("\\VarFileInfo\\Translation"),
(LPVOID*)&lpTranslations,
&cbTranslations);
if (!exists)
{
// No translation information.
}
else
{
hr = StringCchPrintf(SubBlock, 50,
TEXT("\\StringFileInfo\\%04x%04x\\FileDescription"),
lpTranslate[i].wLanguage,
lpTranslate[i].wCodePage);
// Read the file description for each language and code page.
for( i=0; i < (cbTranslations/sizeof(struct LANGANDCODEPAGE)); i++ )
{
hr = StringCchPrintf(
SubBlock,
50,
TEXT("\\StringFileInfo\\%04x%04x\\FileDescription"),
lpTranslations[i].wLanguage,
lpTranslations[i].wCodePage);
if (FAILED(hr))
{
// TODO: write error handler.
// Handle error
}

// Retrieve file description for language and code page "i".
exists = VerQueryValue(
pBlock,
SubBlock,
&lpBuffer,
&dwBytes);
if (exists)
{
// Do something with the data.
}

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






> [!NOTE]
> The winver.h header defines VerQueryValue as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see [Conventions for Function Prototypes](/windows/win32/intl/conventions-for-function-prototypes).

Expand Down
67 changes: 42 additions & 25 deletions sdk-api-src/content/winver/nf-winver-verqueryvaluew.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,40 +169,57 @@ Be sure to call the <a href="/windows/desktop/api/winver/nf-winver-getfileversio


```cpp

// Structure used to store enumerated languages and code pages.
typedef struct {
WORD wLanguage;
WORD wCodePage;
} LANGANDCODEPAGE;

LANGANDCODEPAGE *lpTranslations;
UINT cbTranslations;
HRESULT hr;

struct LANGANDCODEPAGE {
WORD wLanguage;
WORD wCodePage;
} *lpTranslate;
BOOL exists;
TCHAR *lpBuffer;
DWORD dwBytes;
TCHAR SubBlock[50];

// 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++ )
exists = VerQueryValue(
pBlock,
TEXT("\\VarFileInfo\\Translation"),
(LPVOID*)&lpTranslations,
&cbTranslations);
if (!exists)
{
hr = StringCchPrintf(SubBlock, 50,
TEXT("\\StringFileInfo\\%04x%04x\\FileDescription"),
lpTranslate[i].wLanguage,
lpTranslate[i].wCodePage);
// No translation information.
}
else
{
// Read the file description for each language and code page.
for( i=0; i < (cbTranslations/sizeof(struct LANGANDCODEPAGE)); i++ )
{
hr = StringCchPrintf(
SubBlock,
50,
TEXT("\\StringFileInfo\\%04x%04x\\FileDescription"),
lpTranslations[i].wLanguage,
lpTranslations[i].wCodePage);
if (FAILED(hr))
{
// TODO: write error handler.
// Handle error
}

// Retrieve file description for language and code page "i".
exists = VerQueryValue(
pBlock,
SubBlock,
&lpBuffer,
&dwBytes);
if (exists)
{
// Do something with the data.
}

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

Expand Down