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 在firemonkey应用程序中使用torientationsensor获取设备倾斜和指南针航向

tidtcpclient控件中文指南

Delphi实现背景音乐播放

Delphi获取进程的命令行参数

Delphi 遍历文件单元文件

Delphi tmsweb core webhttprequest1提交json数据

Delphi 移动桌面图标

Delphi假死线程堵塞解决办法

Delphi 十六进制数转换十进制数

Delphi 10.4中新增功能:新的vcl tedgebrowser组件

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



打赏

取消

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

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

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

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

评论

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