function TForm1.GetVersion: string;
var
dwHandle, dwLen, puLen: Cardinal;
lpData: array[0..1023] of Char;
tmpInfo: pchar;
lpSubBlock: string;
lplpPointer: Pointer;
Lang: dword;
begin
tmpInfo := StrAlloc(256);
dwLen := GetFileVersionInfoSize(pchar(Edit1.Text), dwHandle);
if dwLen = 0 then exit;
if not GetFileVersionInfo(pchar(Edit1.Text), dwHandle, dwLen, @lpData) then
exit;
lpSubBlock := '/VarFileInfo/Translation';
if VerQueryValue(@lpData, pchar(lpSubBlock), lplpPointer, puLen) then begin
Lang := dword(lplpPointer^);
//取得版本号
lpSubBlock := Format('/StringFileInfo/%.04X%.04X/FileVersion',
[LoWord(Lang), HiWord(Lang)]);
if VerQueryValue(@lpData, pchar(lpSubBlock), lplpPointer, puLen) then begin
StrCopy(tmpInfo, lplpPointer);
Result := 'V[' + StrPas(tmpInfo) + ']';
end;
end;
StrDispose(tmpInfo);
end;///貌似上面有啦,拣着用吧[
]