示例#1
0
        public static FileHash GetFileHash(string path)
        {
            MSIFILEHASHINFO hash = new MSIFILEHASHINFO();

            hash.dwFileHashInfoSize =
                (UInt32)Marshal.SizeOf(typeof(MSIFILEHASHINFO));
            TR(MsiGetFileHash(path, 0, ref hash));
            FileHash result = new FileHash();

            result.Data = new UInt32[4]
            {
                hash.dwData1, hash.dwData2, hash.dwData3, hash.dwData4
            };
            return(result);
        }
示例#2
0
        /// <summary>
        /// Takes the path to a file and returns a 128-bit hash of that file.
        /// </summary>
        /// <param name="filePath">Path to file that is to be hashed.</param>
        /// <param name="options">The value in this column must be 0. This parameter is reserved for future use.</param>
        /// <param name="hash">Int array that receives the returned file hash information.</param>
        internal static void GetFileHash(string filePath, int options, out int[] hash)
        {
            MSIFILEHASHINFO hashInterop = new MSIFILEHASHINFO();

            hashInterop.FileHashInfoSize = 20;

            int error = MsiInterop.MsiGetFileHash(filePath, Convert.ToUInt32(options), hashInterop);

            if (0 != error)
            {
                throw new MsiException(error);
            }

            Debug.Assert(20 == hashInterop.FileHashInfoSize);

            hash    = new int[4];
            hash[0] = hashInterop.Data0;
            hash[1] = hashInterop.Data1;
            hash[2] = hashInterop.Data2;
            hash[3] = hashInterop.Data3;
        }
示例#3
0
 internal static extern int MsiGetFileHash(string filePath, uint options, MSIFILEHASHINFO hash);
示例#4
0
 internal static extern int MsiGetFileHash(string filePath, uint options, MSIFILEHASHINFO hash);
示例#5
0
 private static extern UInt32 MsiGetFileHash(string path,
                                             int options, ref MSIFILEHASHINFO hash);