我是这样显示应用程序的版本号的 不过,先得Project-->Options 选择Version Info这一页,选中Include version information in project//得到本程序的版本号的自定义函数 function TForm1.GetFileVersion(fn: string; var ma, mi, r, b: integer): boolean; var buf, p: pChar; sver: ^VS_FIXEDFILEINFO ; i: LongWord; begin i:= GetFileVersionInfoSize(pchar(fn), i); new(sver); p:= pchar(sver); GetMem(buf, i); ZeroMemory(buf, i); result:= false; if GetFileVersionInfo(pchar(fn), 0, 4096, pointer(buf)) then if VerQueryValue(buf, '\', pointer(sver), i) then begin ma:= sVer^.dwFileVersionMS shr 16; mi:= sver^.dwFileVersionMS and $0000ffff; r:= sver^.dwFileVersionLS shr 16; b:= sver^.dwFileVersionLS and $0000ffff; result:= true; end; Dispose(p); FreeMem(buf); end;procedure TForm1.FormShow(Sender: TObject); Var ma,mi,r,b,mColor:integer; begin if GetFileVersion(Application.ExeName,ma,mi,r,b) then Label1.Caption :=' Ver:'+intTostr(ma)+'.'+intTostr(mi)+intTostr(r)+intTostr(b); end; 我是把版本号显示在Label中,你想显示在Edit里面也是一样的
function TForm1.GetOS:string; var OS :TOSVersionInfo; begin ZeroMemory(@OS,SizeOf(OS)); OS.dwOSVersionInfoSize:=SizeOf(OS); GetVersionEx(OS); //Result:=osUnknown; if OS.dwPlatformId=VER_PLATFORM_WIN32_NT then begin case OS.dwMajorVersion of 3: Result:='osNT3'; 4: Result:='osNT4'; 5: begin if OS.dwMinorVersion>=1 then Result:='osXP' else Result:='os2K'; end; end; end else begin if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=0) then begin Result:='os95'; if (Trim(OS.szCSDVersion)='B') then Result:='os95OSR2'; end else if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=10) then begin Result:='os98'; if (Trim(OS.szCSDVersion)='A') then Result:='os98SE'; end else if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=90) then Result:='osME'; end; end;
不过,先得Project-->Options
选择Version Info这一页,选中Include version information in project//得到本程序的版本号的自定义函数
function TForm1.GetFileVersion(fn: string; var ma, mi, r,
b: integer): boolean;
var
buf, p: pChar;
sver: ^VS_FIXEDFILEINFO ;
i: LongWord;
begin
i:= GetFileVersionInfoSize(pchar(fn), i);
new(sver);
p:= pchar(sver);
GetMem(buf, i);
ZeroMemory(buf, i);
result:= false;
if GetFileVersionInfo(pchar(fn), 0, 4096, pointer(buf)) then
if VerQueryValue(buf, '\', pointer(sver), i) then begin
ma:= sVer^.dwFileVersionMS shr 16;
mi:= sver^.dwFileVersionMS and $0000ffff;
r:= sver^.dwFileVersionLS shr 16;
b:= sver^.dwFileVersionLS and $0000ffff;
result:= true;
end;
Dispose(p);
FreeMem(buf);
end;procedure TForm1.FormShow(Sender: TObject);
Var
ma,mi,r,b,mColor:integer;
begin
if GetFileVersion(Application.ExeName,ma,mi,r,b) then
Label1.Caption :=' Ver:'+intTostr(ma)+'.'+intTostr(mi)+intTostr(r)+intTostr(b);
end;
我是把版本号显示在Label中,你想显示在Edit里面也是一样的
var
OS :TOSVersionInfo;
begin
ZeroMemory(@OS,SizeOf(OS));
OS.dwOSVersionInfoSize:=SizeOf(OS);
GetVersionEx(OS);
//Result:=osUnknown;
if OS.dwPlatformId=VER_PLATFORM_WIN32_NT then
begin
case OS.dwMajorVersion of
3: Result:='osNT3';
4: Result:='osNT4';
5: begin
if OS.dwMinorVersion>=1 then
Result:='osXP'
else
Result:='os2K';
end;
end;
end
else
begin
if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=0) then
begin
Result:='os95';
if (Trim(OS.szCSDVersion)='B') then
Result:='os95OSR2';
end
else
if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=10) then
begin
Result:='os98';
if (Trim(OS.szCSDVersion)='A') then
Result:='os98SE';
end
else
if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=90) then
Result:='osME';
end;
end;