下面这个代码不需要组件一样可以获取MD5值。

复制代码 代码如下:

Option Explicit

Dim wi

Dim file

Dim file_size

Dim file_attributes

Dim file_version

Dim file_hash

Set wi = CreateObject(“WindowsInstaller.Installer”)

file = “111.exe”

file_size = wi.FileSize(file)

file_attributes = wi.FileAttributes(file)

file_version = wi.FileVersion(file)

file_hash = GetFileHash(file)

Set wi = Nothing

MsgBox “File: ” & file & vbCrLf & _

“Size: ” & file_size & vbCrLf & _

“Attributes: ” & file_attributes & vbCrLf & _

“Version: ” & file_version & vbCrLf & _

“MD5: ” & file_hash

Function GetFileHash(file_name)

Dim file_hash

Dim hash_value

Dim i

Set file_hash = wi.FileHash(file_name, 0)

hash_value = “”

For i = 1 To file_hash.FieldCount

hash_value = hash_value & BigEndianHex(file_hash.IntegerData(i))

Next

GetFileHash = hash_value

Set file_hash = Nothing

End Function

Function BigEndianHex(Int)

Dim result

Dim b1, b2, b3, b4

result = Hex(Int)

b1 = Mid(result, 7, 2)

b2 = Mid(result, 5, 2)

b3 = Mid(result, 3, 2)

b4 = Mid(result, 1, 2)

BigEndianHex = b1 & b2 & b3 & b4

End Function

您可能感兴趣的文章:

声明:本站(华域联盟www.cnhackhy.com)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。