MsgBox(0,"c:\windows\explorer.exe",_GetMD5("c:\windows\explorer.exe"))
Func _GetMD5($_FILES)
if FileExists($_FILES) then
$iAlgID = 0x8003
$_FILES_Open=FileOpen($_FILES, 16)
$_FILES_Read=FileRead($_FILES_Open)
FileClose($_FILES)
$vData=$_FILES_read
Local $iLen = BinaryLen($vData), $hContext, $hHash, $aRet, $sRet = "", $iErr = 0, $tDat = DllStructCreate("byte[" & $iLen + 1 & "]"), $tBuf
DllStructSetData($tDat, 1, $vData)
$aRet = DllCall("advapi32.dll", 'int', 'CryptAcquireContext', 'ptr*', 0, 'ptr', 0, 'ptr', 0, 'dword', 1, 'dword', 0xF0000000)
If Not @error And $aRet[0] Then
$hContext = $aRet[1]
$aRet = DllCall("advapi32.dll", 'int', 'CryptCreateHash', 'ptr', $hContext, 'dword', $iAlgID, 'ptr', 0, 'dword', 0, 'ptr*', 0)
If $aRet[0] Then
$hHash = $aRet[5]
$aRet = DllCall("advapi32.dll", 'int', 'CryptHashData', 'ptr', $hHash, 'ptr', DllStructGetPtr($tDat), 'dword', $iLen, 'dword', 0)
If $aRet[0] Then
$aRet = DllCall("advapi32.dll", 'int', 'CryptGetHashParam', 'ptr', $hHash, 'dword', 2, 'ptr', 0, 'int*', 0, 'dword', 0)
$tBuf = DllStructCreate("byte[" & $aRet[4] & "]")
DllCall("advapi32.dll", 'int', 'CryptGetHashParam', 'ptr', $hHash, 'dword', 2, 'ptr', DllStructGetPtr($tBuf), 'int*', $aRet[4], 'dword', 0)
$sRet = Hex(DllStructGetData($tBuf, 1))
Else
$iErr = 3
EndIf
DllCall("advapi32.dll", 'int', 'CryptDestroyHash', 'ptr', $hHash)
Else
$iErr = 2
EndIf
DllCall("advapi32.dll", 'int', 'CryptReleaseContext', 'ptr', $hContext, 'dword', 0)
Else
$iErr = 1
EndIf
Return SetError($iErr, 0, $sRet)
endif
EndFunc
|