Addendum

Key Windows API Functions

GetFileVersionInfoSizeA()

Docs

Determines whether the OS can retrieve version info for a file. If successful, returns the size in bytes.

DWORD GetFileVersionInfoSizeA(
  [in]            LPCSTR  lptstrFilename,    // name of the file of interest
  [out, optional] LPDWORD lpdwHandle         // pointer to a variable that the function sets to zero
);

Return Value: Size in bytes if successful, otherwise 0.


GetFileVersionInfoA()

Docs

Retrieves version info for the specified file. Requires prior call to GetFileVersionInfoSize.

BOOL GetFileVersionInfoA(
  [in]  LPCSTR lptstrFilename,        // name of the file
        DWORD  dwHandle,              // parameter ignored
  [in]  DWORD  dwLen,                 // the size (in bytes) of lpData buffer
  [out] LPVOID lpData                 // pointer to buffer receiving the version info
);

Return Value: Nonzero if successful, 0 if failed.


VerQueryValueA()

Docs

Retrieves specified version info from a version-information resource.

BOOL VerQueryValueA(
  [in]  LPCVOID pBlock,          // version-information resource returned by the GetFileVersionInfo
  [in]  LPCSTR  lpSubBlock,      // version-information value to be retrieved
  [out] LPVOID  *lplpBuffer,     // contains the address of a pointer in the buffer pointed to by pBlock
  [out] PUINT   puLen            // contains a pointer to the size of the requested data
);

Return Value: Nonzero if successful, otherwise 0.


Key Windows API Structures

VS_FIXEDFILEINFO

Contains version info for a file. Defined in verrsrc.h.

typedef struct tagVS_FIXEDFILEINFO {
  DWORD dwSignature;          // contains the value 0xFEEF04BD
  DWORD dwStrucVersion;       // binary version number of this structure
  DWORD dwFileVersionMS;      // most significant 32 bits of the file's binary version number
  DWORD dwFileVersionLS;      // least significant 32 bits of the file's binary version number
  DWORD dwProductVersionMS;   // most significant 32 bits of the binary version number of the product
  DWORD dwProductVersionLS;   // least significant 32 bits of the binary version number of the product
  DWORD dwFileFlagsMask;      // bitmask that specifies the valid bits in dwFileFlags
  DWORD dwFileFlags;          // bitmask that specifies the Boolean attributes of the file
  DWORD dwFileOS;             // operating system for which this file was designed
  DWORD dwFileType;           // general type of file, ex. DLL, DRV, FONT, etc.
  DWORD dwFileSubtype;        // function of the file
  DWORD dwFileDateMS;         // most significant 32 bits of the file's 64-bit binary creation date 
  DWORD dwFileDateLS;         // least significant 32 bits of the file's 64-bit binary creation date
} VS_FIXEDFILEINFO;