4.12 Version Resources

Version resources specify information that can be used by setup programs to discover which of several versions of a program or dynamic-link library to install into the system. There is also a set of APIs to query the version resources. There are three major types of information stored in version resources: the main information in a VS_FIXEDFILEINFO structure, Language information data in a variable file information structure (VarFileInfo), and user-defined string information in StringFileInfo structures. For Win32, the strings within the version information resource are stored in Unicode, providing localization of the resources. Each block of information is DWORD-aligned.

The structure of a version resource is depicted by the VS_VERSION_INFO structure.


VS_VERSION_INFO {
  WORD wLength;      /* Length of the version resource */
  WORD wValueLength  /* Length of the value field for this block */
  WORD wType;        /* Type of information: 1==string, 0==binary */
  WCHAR szKey[];     /* Unicode string KEY field */
  [WORD Padding1;]   /* Possible word of padding */
  VS_FIXEDFILEINFO Value;  /* Fixed File Info Structure */
  BYTE Children[];   /* Position of VarFileInfo or StringFileInfo 
                        data */
};

The Fixed File Info structure contains basic information about the version, including version numbers for the product and file, and type of the file.


typedef struct tagVS_FIXEDFILEINFO { 
  DWORD dwSignature;         /* signature - always 0xfeef04bd */
  DWORD dwStrucVersion;      /* structure version - currently 0 */
  DWORD dwFileVersionMS;   /* Most significant file version dword */
  DWORD dwFileVersionLS;  /* Least significant file version dword */
  DWORD dwProductVersionMS;  /* Most significant product version */
  DWORD dwProductVersionLS;  /* Least significant product version */
  DWORD dwFileFlagMask;      /* File flag mask */
  DWORD dwFileFlags;         /* Debug/retail/prerelease/... */
  DWORD dwFileOS;      /* OS type. Will always be Windows32 value */
  DWORD dwFileType;          /* Type of file (dll/exe/drv/... )*/
  DWORD dwFileSubtype;       /* File subtype */
  DWORD dwFileDateMS;        /* Most significant part of date */
  DWORD dwFileDateLS;        /* Least significant part of date */
} VS_FIXEDFILEINFO;

The user-defined string information is contained within the StringFileInfo structure, which is a set of two strings: the key and the information itself.


StringFileInfo {
  WCHAR    szKey[];          /* Unicode "StringFileInfo" */
  [WORD    padding;]         /* Possible padding */
  StringTable Children[];    /* 
};

StringTable {
  WCHAR   szKey[];   /* Unicode string denoting the language--8 
                        bytes */
  String Children[];  /* Array of children string structures */
}

String {
  WCHAR  szKey[];        /* Arbitrary Unicode encoded KEY string */
                  /* Note that there is a list of predefined keys */
  [WORD  padding;]       /* Possible padding */
  WCHAR Value[];         /* Unicode-encoded value for KEY */
} String;

The variable file information (VarFileInfo) block contains a list of languages supported by this version of the application/DLL.


VarFileInfo {
  WCHAR     szKey[];          /* Unicode "VarFileInfo" */
  [WORD     padding;];        /* Possible padding */
  Var       Children[];       /* Children array */
};

Var {
  WCHAR   szKey[];   /* Unicode "Translation" (or other user key) */
  [WORD   padding;]  /* Possible padding */
  WORD    Value[];   /* One or more values, normally language IDs */
};