MsiGetFileVersion Function

Windows Installer

MsiGetFileVersion Function

The MsiGetFileVersion returns the version string and language string in the format that the installer expects to find them in the database. If you want only version information, set lpLangBuf and pcchLangBuf to 0 (zero). If you just want language information, set lpVersionBuf and pcchVersionBuf to 0 (zero).

Syntax

C++UINT MsiGetFileVersion(
  __in     LPCTSTR szFilePath,
  __out    LPTSTR lpVersionBuf,
  __inout  DWORD *pcchVersionBuf,
  __out    LPTSTR lpLangBuf,
  __inout  DWORD *pcchLangBuf
);

Parameters

szFilePath [in]

Specifies the path to the file.

lpVersionBuf [out]

Returns the file version.

Set to 0 for language information only.

pcchVersionBuf [in, out]

In and out buffer count as the number of TCHAR.

Set to 0 (zero) for language information only. On input, this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, the count returned does not include the terminating null character.

lpLangBuf [out]

Returns the file language.

Set to 0 (zero) for version information only.

pcchLangBuf [in, out]

In and out buffer count as the number of TCHAR.

Set to 0 (zero) for version information only. On input, this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, the count returned does not include the terminating null character.

Return Value

Value Meaning
ERROR_SUCCESS

Successful completion.

ERROR_FILE_NOT_FOUND

File does not exist.

ERROR_ACCESS_DENIED

File cannot be opened to get version information.

ERROR_FILE_INVALID

File does not contain version information.

ERROR_INVALID_DATA

The version information is invalid.

E_FAIL

Unexpected error.

 

Requirements

VersionWindows Installer 5.0 on Windows Server 2008 R2 or Windows 7. Windows Installer 4.0 or Windows Installer 4.5 on Windows Server 2008 or Windows Vista. Windows Installer on Windows Server 2003, Windows XP, and Windows 2000. See the Windows Installer Run-Time Requirements for information about the minimum Windows service pack that is required by a Windows Installer version.
HeaderMsi.h
LibraryMsi.lib
DLLMsi.dll
Unicode and ANSI namesMsiGetFileVersionW (Unicode) and MsiGetFileVersionA (ANSI)

See Also

System Status Functions

Send comments about this topic to Microsoft

Build date: 8/13/2009

© 2009 Microsoft Corporation. All rights reserved.