网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 vbs获取文件md5值(无组件)
范文
    vbs获取md5值最简单的方法是直接调用capicom组件,但是由于capicom组件系统并不是默认安装,所以使用起来不方便
    下面这个代码不需要组件一样可以获取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
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/21 16:35:01