获取文件MD5的两种方法
方式1: 通过certutil命令获取:;;;参数file --文件名
(defun GetMD5FromFile (file / wsh res txt idx cmd)
(setq wsh (vlax-create-object "wscript.shell"))
(setq cmd (strcat "certutil -hashfile \""file "\" MD5"))
(setq res (vlax-invoke wsh 'exec cmd))
(setq txt (vlax-invoke (vlax-get res 'stdout) 'readall))
(setq idx (VL-STRING-POSITION (ascii "\r") txt))
(setq txt (substr txt (+ idx 3)))
(setq idx (VL-STRING-POSITION (ascii "\r") txt))
(setq txt (substr txt 1 idx))
(vlax-release-object wsh)
txt
)
方式2: 通过WindowsInstaller.installer类获取.
(defun GetMD5 (file / HASH H COUNT I S V WCS WI)
(if
(or
(setq wcs (vlax-create-object "Aec32BitAppServer.AecScriptControl.1"))
(setq wcs (vlax-create-object "ScriptControl"))
)
(vlax-put-property wcs "language" "VBScript")
)
(setq wi (vlax-create-object "WindowsInstaller.installer"))
;;(setq size (vlax-invoke wi 'filesize file))
;;(setq version (vlax-invoke wi 'fileversion file))
(setq hash (vlax-invoke wi 'filehash file 0))
(setq count (vlax-get-property hash 'FieldCount))
(setq i 1)
(setq s "")
(repeat count
(setq v (vlax-get-property hash 'IntegerData i))
(setq v (rtos v 2 0))
(setq H (vlax-invoke wcs 'eval (strcat "hex(" v ")")))
(while (< (strlen H) 8)
(setq H (strcat "0" H))
)
(setq s (strcat s
(substr H 7 2)
(substr H 5 2)
(substr H 3 2)
(substr H 1 2)
)
)
(setq i (1+ i))
)
(vlax-release-object hash)
(vlax-release-object wcs)
(vlax-release-object wi)
s
)
用法示例:
(getMD5FromFile "c:\\temp\\test.exe")
(getMD5 "c:\\temp\\test.exe")
存在就是合理的另一种说法{:1_12:} {:1_10:}{:1_14:}{:1_18:} 想请问大师一个问题,往表格的单元格里插入块应该用什么函数,不胜感激。 字符串的MD5怎么获取 学习一下两种方法。感谢分享。
页:
[1]