The MsiGetFileHash function takes the path to a file and returns a 128-bit hash of that file. Authoring tools may use MsiGetFileHash to obtain the file hash needed to populate the MsiFileHash table.
Windows Installer uses file hashing as a means to detect and eliminate unnecessary file copying. A file hash stored in the MsiFileHash table may be compared to a hash of an existing file on the user's computer.
UINT MsiGetFileHashA( LPCSTR szFilePath, DWORD dwOptions, PMSIFILEHASHINFO pHash );
Path to file that is to be hashed.
The value in this column must be 0. This parameter is reserved for future use.
Pointer to the returned file hash information.
||The function completed successfully.|
||The file does not exist.|
||The file could not be opened to get version information.|
||Unexpected error has occurred.|
The entire 128-bit file hash is returned as four 32-bit fields. The numbering of the four fields is zero-based. The values returned by MsiGetFileHash correspond to the four fields of the MSIFILEHASHINFO structure. The first field corresponds to the HashPart1 column of the MsiFileHash table, the second field corresponds to the HashPart2 column, the third field corresponds to the HashPart3 column, and the fourth field corresponds to the HashPart4 column.
The hash information entered into the MsiFileHash table must be obtained by calling MsiGetFileHash or the FileHash method. Do not attempt to use other methods to generate the file hash.
|Minimum supported client||Windows Installer 5.0 on Windows Server 2012, Windows 8, 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 or Windows XP. See the Windows Installer Run-Time Requirements for information about the minimum Windows service pack that is required by a Windows Installer version.|