Delphi 取得文件版本


本文整理自网络,侵删。

 
//取得文件版本
function GetFileVer(strFileName: String): String;
var
    n, Len: DWORD;
    Buf : PChar;
    Value: Pointer;
    szName: array [0..255] of Char;
    Transstring: String;
begin
    Len := GetFileVersionInfoSize(PChar(strFileName), n);
    if Len > 0 then
    begin
        Buf := AllocMem(Len);
        if GetFileVersionInfo(Pchar(strFileName), n, Len, Buf) then
        begin
            Value := nil;
            VerQueryValue(Buf, '\VarFileInfo\Translation', Value, Len);
            if Value <> nil then
            begin
                Transstring := IntToHex(MakeLong(HiWord(LongInt(Value^)), LoWord(LongInt(Value^))),8);
            end;
            StrPCopy(szName, '\stringFileInfo\' + Transstring + '\FileVersion');
            if VerQueryValue(Buf, szName, Value, Len) then
            begin
                Result := StrPas(Pchar(Value));
            end;
            FreeMem(Buf, n);
        end;
    end;
end;

相关阅读 >>

Delphi 比较两个位图是否相同

Delphi实现文件防删除

Delphi xe 中的字符串生成哈希值(md5 / sha-1 / jenkins)

Delphi 关于虚拟的desktop的编程

Delphi 是否是闰年- isleapyear、isinleapyear

Delphi使焦点固定到一个button上

屏幕抓取Delphi

wmi技术介绍和应用

Delphi 获取memo文本光标的位置

Delphi 中 unicode 转汉字 函数

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...