MsiGetFileHashA function (msi.h)
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.
Syntax
UINT MsiGetFileHashA(
[in] LPCSTR szFilePath,
[in] DWORD dwOptions,
[out] PMSIFILEHASHINFO pHash
);
Parameters
[in] szFilePath
Path to file that is to be hashed.
[in] dwOptions
The value in this column must be 0. This parameter is reserved for future use.
[out] pHash
Pointer to the returned file hash information.
Return value
Value | Meaning |
---|---|
|
The function completed successfully. |
|
The file does not exist. |
|
The file could not be opened to get version information. |
|
Unexpected error has occurred. |
Remarks
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.
Note
The msi.h header defines MsiGetFileHash as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
Requirement | Value |
---|---|
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. |
Target Platform | Windows |
Header | msi.h |
Library | Msi.lib |
DLL | Msi.dll |