来自:cAkk 时间:1999-10-5 15:09:09 ID:139642 <br>下面的函数可以得到文件的版本信息,注意,delphi做的程序,如果想<br>包含版本信息, 必须在菜单"project/options/version info"里面<br>添加版本信息.<br>function GetVersion;<br>var<br> InfoSize, Wnd: DWORD;<br> VerBuf: Pointer;<br> szName: array[0..255] of Char;<br> Value: Pointer;<br> Len: UINT;<br> TransString:string;<br>begin<br> InfoSize := GetFileVersionInfoSize(PChar(FileName), Wnd);<br> if InfoSize <> 0 then<br> begin<br> GetMem(VerBuf, InfoSize);<br> try<br> if GetFileVersionInfo(PChar(FileName), Wnd, InfoSize, VerBuf) then<br> begin<br> Value :=nil;<br> VerQueryValue(VerBuf, '/VarFileInfo/Translation', Value, Len);<br> if Value <> nil then<br> TransString := IntToHex(MakeLong(HiWord(Longint(Value^)), LoWord(Longint(Value^))), 8);<br> Result := '';<br> StrPCopy(szName, '/StringFileInfo/'+Transstring+'/FileVersion');<br> ^^^^^^^此处换成ProductVersion得到的是"产品版本"<br> if VerQueryValue(VerBuf, szName, Value, Len) then<br> Result := StrPas(PChar(Value));<br> end;<br> finally<br> FreeMem(VerBuf);<br> end;<br> end;<br>end;<br><br> <br> <br><br>--------------------------------------------------------------------------------<br>来自:cAkk 时间:1999-10-5 15:43:42 ID:139661 <br>更正,函数声明为:<br>function GetVersion(filename:string):string;<br><br>忘了加参数了.
<br><br> <br> <br>