uLib  User mode C/C++ extended API library for Win32 programmers.
Version String Enumeration

Module Description

Easy enumeration of version info string blocks.
#include <uLib/VerInfo.h>

Classes

struct  PVXLT
 

Typedefs

typedef void(__stdcall * PFnEnumVerStr) (CSTR Name, CSTR Val, PVOID UserData)
 

Functions

UINT EnumVersionStrings (PVOID vInfo, PFnEnumVerStr Action, PVOID UserData)
 
int AboutVerBox (HWND hOwner, LPCWSTR Caption, CSTR FName=NULL)
 
PVOID GetVersionResource (HMODULE hMod, CSTR ResId, PUINT pSize)
 
PVOID LoadVersionInfo (CSTR FName, PDWORD pSize)
 
PVOID FreeVersionInfo (PVOID vInfo)
 
CSTR GetFixedVersionStr (IN PVOID vInfo)
 
UINT GetVersionString (IN PVOID VerBuf, IN CSTR BlockId, IN CSTR Name, OUT TSTR Buffer, IN UINT BufLen)
 Get a specific version string. More...
 
bool GetVerTranslations (IN PVOID vInfo, OUT PVXLT *ppXlt, OUT PUINT pCount)
 
CSTR GetVerTranslationStr (IN PVOID vInfo)
 

Variables

CCSTR V_ProdName = _T("ProductName")
 
CCSTR V_ProdVer = _T("ProductVersion")
 
CCSTR V_Copyright = _T("LegalCopyright")
 
CCSTR V_Company = _T("CompanyName")
 
CCSTR V_Descript = _T("FileDescription")
 
CCSTR V_Comments = _T("Comments")
 
CCSTR V_EnUniBlock = _T("040904B0")
 US English / Unicode. More...
 
CCSTR V_EnMultiBlock = _T("040904E4")
 US English / Codepage 1252. More...
 

Class Documentation

◆ VXLT

struct VXLT

Resource language specification. Usage example:

PVXLT pXlt; UINT len;
if (GetVerTranslations( vInfo, &pXlt, &len ))
_stprintf_s( szXlt, dimof(szXlt), _T("%04X%04X"), pXlt[0].Lang, pXlt[0].Cp );

See also V_EnMultiBlock, V_EnUniBlock for some predefined ones.

Definition at line 121 of file VerInfo.h.

Class Members
WORD Lang Microsoft langage Id.
WORD Cp IBM codepage.

Typedef Documentation

◆ PFnEnumVerStr

typedef void(__stdcall * PFnEnumVerStr) (CSTR Name, CSTR Val, PVOID UserData)

Action callback for EnumVersionStrings().

Parameters
NameVersion string identifier, f.ex. ProductName.
ValVersion string value. f.ex. Microsoft Windows.
UserDataArbitrary data passed in to EnumVersionStrings.

Definition at line 26 of file VerInfo.h.

Function Documentation

◆ EnumVersionStrings()

UINT EnumVersionStrings ( PVOID  vInfo,
PFnEnumVerStr  Action,
PVOID  UserData 
)

Enumerate the strings in a version info block.

Parameters
vInfoVersion info block to enumerate.
ActionYour enumeration callback function.
UserDataWhatever your Action callback might need.

Note: Enumerates the first string info block it finds (if more than one).

Definition at line 249 of file VerInfo.cpp.

◆ AboutVerBox()

int AboutVerBox ( HWND  hOwner,
LPCWSTR  Caption,
CSTR  FName = NULL 
)

AboutVerBox shows version strings and module bitness in a dialog box.
It uses a memory template, so it doesn't need a dialog resource. Hence it can live comfortably in a library.

Parameters
hOwnerOwner of the dialog box.
CaptionDialog title. Note that this has to be a wide string, since it's inserted verbatim in the template.
FNameFilename containing the version resource. Use NULL to indicate the current process.

Definition at line 326 of file VerInfo.cpp.

◆ GetVersionResource()

PVOID GetVersionResource ( HMODULE  hMod,
CSTR  ResId,
PUINT  pSize 
)

Get a R/O pointer directly to the version resource.

Parameters
[in]hModHandle of the resource module. Use NULL for the current process.
[in]ResIdId of the version resource.
[out]pSize[optional] Recieves the size of the version resource.

Note: Some Win32 APIs, e.g VerQueryValueA, may flip the lid on this pointer,
since they expect the memory block to be writable (which it isn't).
(The VerQueryValueA issue is the resource string translation from Unicode to ANSI,
so remember to only use GetVersionStr() or VerQueryValueW for the strings.)

Definition at line 23 of file VerInfo.cpp.

◆ LoadVersionInfo()

PVOID LoadVersionInfo ( CSTR  FName,
PDWORD  pSize 
)

Load version info from a file into dynamic memory.

Parameters
[in]FNameFilename of the resource module. Use NULL for the current process.
[out]pSize[optional] Recieves the size of the version info.

Dispose with FreeVersionInfo() when you're done.

Definition at line 29 of file VerInfo.cpp.

◆ FreeVersionInfo()

PVOID FreeVersionInfo ( PVOID  vInfo)

Free memory from LoadVersionInfo().

Definition at line 59 of file VerInfo.cpp.

◆ GetFixedVersionStr()

CSTR GetFixedVersionStr ( IN PVOID  vInfo)

Get the VS_FIXEDFILEINFO as a dotted version string.

Parameters
vInfoA pointer to the version info block.

◆ GetVersionString()

UINT GetVersionString ( IN PVOID  VerBuf,
IN CSTR  BlockId,
IN CSTR  Name,
OUT TSTR  Buffer,
IN UINT  BufLen 
)

Get a specific version string.

Get a specific version string.

Parameters
vInfoPointer to the version info block.
BlockIdLanguage id of the StringFileInfo, f.ex. "040904E4".
NameVersion string identifier, f.ex. ProductName.
BufferRecieves the version string.
BufLenLength, in TCHARs, of the recieving Buffer.

See also VXLT, GetVerTranslationStr().

Definition at line 133 of file VerInfo.cpp.

◆ GetVerTranslations()

bool GetVerTranslations ( IN PVOID  vInfo,
OUT PVXLT *  ppXlt,
OUT PUINT  pCount 
)

Get the available resource language versions.

Parameters
ppXltRecieves a pointer to the translations.
pCountRecieves the count of translations in the array.

◆ GetVerTranslationStr()

CSTR GetVerTranslationStr ( IN PVOID  vInfo)

Get the first \VarFileInfo\Translation of the resource.
Uses an internal static buffer. On failure, it returns an empty string.
See also VXLT

Variable Documentation

◆ V_ProdName

CCSTR V_ProdName = _T("ProductName")

Definition at line 103 of file VerInfo.h.

◆ V_ProdVer

CCSTR V_ProdVer = _T("ProductVersion")

Definition at line 104 of file VerInfo.h.

◆ V_Copyright

CCSTR V_Copyright = _T("LegalCopyright")

Definition at line 105 of file VerInfo.h.

◆ V_Company

CCSTR V_Company = _T("CompanyName")

Definition at line 106 of file VerInfo.h.

◆ V_Descript

CCSTR V_Descript = _T("FileDescription")

Definition at line 107 of file VerInfo.h.

◆ V_Comments

CCSTR V_Comments = _T("Comments")

Definition at line 108 of file VerInfo.h.

◆ V_EnUniBlock

CCSTR V_EnUniBlock = _T("040904B0")

US English / Unicode.

Definition at line 143 of file VerInfo.h.

◆ V_EnMultiBlock

CCSTR V_EnMultiBlock = _T("040904E4")

US English / Codepage 1252.

Definition at line 144 of file VerInfo.h.