#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Icon=G:\素材大全\图标资源\系统图标\51(1).ico
#AutoIt3Wrapper_Res_Comment=计算文件的MD5值
#AutoIt3Wrapper_Res_Description=计算文件的MD5值
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_LegalCopyright=阿福所有 侵权不究
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ACN_HASH.au3>
Global $Hash, $FileHandle, $Filename, $Buffersize = 0x20000
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("计算文件的MD5值", 364, 71, -1, -1, -1, $WS_EX_ACCEPTFILES)
GUISetIcon("G:\素材大全\图标资源\系统图标\51(1).ico", -1)
$Button1 = GUICtrlCreateButton("浏览", 312, 4, 43, 25)
$Input2 = GUICtrlCreateInput("", 8, 40, 297, 21)
$Button2 = GUICtrlCreateButton("复制", 312, 36, 43, 25)
$Input1 = GUICtrlCreateInput("浏览或拖曳一个文件到这里", 8, 8, 297, 21)
GUICtrlSetState(-1, 8)
;GUICtrlSetState(-1, 128) ;禁用
$Filename = GUICtrlRead($Input1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
ClipPut(GUICtrlRead($Input2))
MsgBox(0, "结果", "已将MD5值复制到剪贴板!", 2)
Case $Button1
$Filename = FileOpenDialog("选择文件", "", "所有文件(*.*)")
If @error <> 1 Then
GUICtrlSetData($Input1, $Filename)
MD5()
EndIf
Case $GUI_EVENT_DROPPED
$_Filename = ControlCommand($Form1, '', $Input1, 'GetSelected', '')
If StringInStr($_Filename, "|") <> 0 Then
GUICtrlSetData($Input1, "浏览或拖曳一个文件到这里")
MsgBox(16, "错误", "一次只能拖曳一个文件!", 5)
GUICtrlSetData($Input1, $Filename)
Else
GUICtrlSetData($Input1, $_Filename)
MD5()
$Filename = $_Filename
EndIf
EndSwitch
WEnd
Func MD5()
GUICtrlSetData($Input2, "计算中,请稍等...")
$FileHandle = FileOpen($_Filename, 16)
$MD5CTX = _MD5Init()
For $i = 1 To Ceiling(FileGetSize($_Filename) / $Buffersize)
_MD5Input($MD5CTX, FileRead($FileHandle, $Buffersize))
Next
$Hash = _MD5Result($MD5CTX)
FileClose($FileHandle)
$Hash = StringTrimLeft($Hash, 2)
$Hash = StringUpper($Hash)
GUICtrlSetData($Input2, $Hash)
EndFunc ;==>MD5