如何用程序得到windows的名称和版本号??(200分)

  • 主题发起人 主题发起人 www
  • 开始时间 开始时间
W

www

Unregistered / Unconfirmed
GUEST, unregistred user!
比如得到Microsoft Windows 2000 Professional,这个是怎么得到的???
版本中 "5.0.2195 Service Pack 2 内部版本号 2195" 是怎么得到的??
 
用GetVersionEx()函数
 
你还可以读系统注册表,
 
使用楼上说的API函数就行了。
 
delphi中有一个全局变量可以得到。
 
大家能不能给出具体的代码??
分数好说.
 
function GetWindowsVersion: string;
var
// windows api structure
VersionInfo: TOSVersionInfo;
begin
// get size of the structure
VersionInfo.dwOSVersionInfoSize := SizeOf(VersionInfo);
// populate the struct using api call
GetVersionEx(VersionInfo);
// platformid gets the core platform
// major and minor versions also included.
with VersionInfo do
begin
case dwPlatformid of
0 : begin
result := 'Windows 3.11';
end; // end 0

1 : begin
case dwMinorVersion of
0 : result := 'Windows 95';
10: begin
if ( szCSDVersion[ 1 ] = 'A' ) then
Result :='Windows 98 SE'
else
Result := 'Windows 98';
end; // end 10
90 : result := 'Windows Millenium';
else
result := 'Unknown Version';
end; // end case
end; // end 1

2 : begin
case dwMajorVersion of
3 : result := 'Windows NT ' +
IntToStr(dwMajorVersion) + '.' +
IntToStr(dwMinorVersion);
4 : result := 'Windows NT ' +
IntToStr(dwMajorVersion) + '.' +
IntToStr(dwMinorVersion);
5 : begin
case dwMinorVersion of
0 : result := 'Windows 2000';
1 : result := 'Windows Whistler';
end; // end case
end; // end 5
else
result := 'Unknown Version';
end; // end case
// service packs apply to the NT/2000 platform
if szCSDVersion <> '' then
result := result + ' Service pack: ' + szCSDVersion;
end; // end 2
else
result := 'Unknown Platform';
end; // end case
// add build info.
result := result + ', Build: ' +
IntToStr(Loword(dwBuildNumber)) ;
end; // end version info
end; // GetWindowsVersion
 
那么这个 "Professional" 是怎么得到的呢???
 
请大家继续帮我.
 
读注册表.
看看//HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/Currentversion
 
请大家继续帮忙.
 
procedure TForm1.Button1Click(Sender: TObject);

var
MyVersionInfo: TOSVersionInfo;
MyReg: TRegistry;
IsNT: Boolean;
begin
MyReg := TRegistry.Create;
MyReg.RootKey := HKEY_LOCAL_MACHINE;

IsNT := False;

MyVersionInfo.dwOSVersionInfoSize := sizeof(TOSVERSIONINFO);

if GetVersionEx(MyVersionInfo) then
Label1.Caption := IntToStr(MyVersionInfo.dwPlatformId)
else Label1.Caption := 'false';

if MyVersionInfo.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS then
Label1.Caption := 'Windows 98';
if MyVersionInfo.dwPlatformId = VER_PLATFORM_WIN32_NT then
begin
IsNT := True;
Label1.Caption := 'Windows NT';
end;

try
if IsNT then
if not MyReg.OpenKey('/SOFTWARE/Microsoft/Windows NT/CurrentVersion', FALSE) then
else Label2.Caption := MyReg.ReadString('CurrentVersion')
else
if not MyReg.OpenKey('/SOFTWARE/Microsoft/Windows/CurrentVersion', FALSE) then
else Label2.Caption := MyReg.ReadString('VersionNumber');
finally
end; // try..finally

end;
 
but I can not get "windows 2000 professional".
where is the "professional" ????????
 
Procedure Tform1.Button1Click(sender:TObject);
Var
OSVI:OSVERSIONINFO;
begin
OSVI.dwOSversioninfoSize:=Sizeof(OSVERSIONINFO);
GetVersionEx(OSVI);
label1.Caption:=IntToStr(OSVI.dwMinorVersion)+','
+IntToStr(OSVI.dwMinorVersion)+','
+IntToStr(OSVI.dwBuildNumber)+','
+IntToStr(OSVI.dwPlatformId)+','
+OSVI.szCSDVersion;
end;

end
 
多人接受答案了。
 
后退
顶部