如果区分Windows的各个版本?(100分)

  • 主题发起人 主题发起人 Milpas
  • 开始时间 开始时间
M

Milpas

Unregistered / Unconfirmed
GUEST, unregistred user!
我要很详细的那种:如Win2k Pro和Win2k Server的区别,WinXP Pro和WinXP Home的区别
因为没装有这么多OS,没办法测试,所以答案最好确定一些

thanks
 
GetVersion() API或者系统常量:
Win32Platform
Win32MajorVersion
Win32MinorVersion
Win32BuildNumber
Win32CSDVersion
 
这个函数我知道,关键是不知道取出来值是哪个对应那个版本
 
给你一个简单的:
const
PlatformA: array[0..2] of string = ('Win32S', 'Windows 95/98/ME', 'Windows NT/2000/XP');
var
AOsName: string;
begin
AOsName := PlatFormA[Win32Platform];
if Win32Platform = 2 then
begin
if Win32MajorVersion = 5 then
case Win32MinorVersion of
0:
AOsName := 'Windows 2000';
1:
AOsName := 'Windows XP';
end;
end;
LabelOS.Caption := Format('%s 版本: %d.%0.2d.%0.4d', [AOsName,
Win32MajorVersion, Win32MinorVersion, Win32BuildNumber]);

要区分哪个是哪个,如95/98/me的,那你就要看各个Windows的具体版本号啦
 
Win2k Pro和Win2k Server的区别,WinXP Pro和WinXP Home的区别 ??????????????

你的程序我没看出来
 
发布 版本 文件日期
------------------------------------------------------------------------
Windows 95 零售,OEM 4.00.950 7/11/95
Windows 95 零售 SP1 4.00.950A 7/11/95-12/31/95
OEM Service Release 2 4.00.1111* (4.00.950B) 8/24/96
OEM Service Release 2.1 4.03.1212-1214* (4.00.950B) 8/24/96-8/27/97
OEM Service Release 2.5 4.03.1214* (4.00.950C) 8/24/96-11/18/97
Windows 98 零售,OEM 4.10.1998 5/11/98
Windows 98 Second Edition 4.10.2222A 4/23/99
Windows Me 4.90.3000
 
好,有没有NT平台的副版本号列表?
我比较需要NT的
 
老兄,贴出来我再给你加100分 [:D]
 
代码:
Platform               High-order bit       Next 7 bits        Low-order byte 
------------------------------------------------------------------------------
Windows NT 3.51            0                 Build number           3 
Windows NT 4.0             0                 Build number           4 
Windows 2000 or            0                 Build number           5
   Windows XP
Windows 95, Windows 98     1                 Reserved               4 
  , or Windows Me 
Win32s with Windows 3.1    1                 Build number           3
 
其实可以用另外一个API(VerifyVersionInfo),可以取得更详细的信息,你要的都可以:
dwMajorVersion
Identifies the major version number of the operating system as follows. Operating System Value
Windows 95 4
Windows 98 4
Windows Me 4
Windows NT 3.51 3
Windows NT 4.0 4
Windows 2000 5
Whistler 5


dwMinorVersion
Identifies the minor version number of the operating system as follows. Operating System Value
Windows 95 0
Windows 98 10
Windows Me 90
Windows NT 3.51 51
Windows NT 4.0 0
Windows 2000 0
Whistler 1
wSuiteMask
A set of bit flags that identify the product suites available on the system. This member can be a combination of the following values. Value Meaning
VER_SUITE_BACKOFFICE Microsoft BackOffice components are installed.
VER_SUITE_DATACENTER Windows 2000 DataCenter Server is installed.
VER_SUITE_ENTERPRISE Windows 2000 Advanced Server is installed.
VER_SUITE_SMALLBUSINESS Microsoft Small Business Server is installed.
VER_SUITE_SMALLBUSINESS_RESTRICTED Microsoft Small Business Server is installed with the restrictive client license in force.
VER_SUITE_TERMINAL Terminal Services is installed.
VER_SUITE_PERSONAL Whistler: Whistler Personal is installed.


wProductType
Indicates additional information about the system. This member can be one of the following values. Value Meaning
VER_NT_WORKSTATION Windows 2000 Professional
VER_NT_DOMAIN_CONTROLLER Windows 2000 domain controller
VER_NT_SERVER Windows 2000 Server
 
你讲的这个API:
VerifyVersionInfo

我查DELPHI帮助没查到,查MS SDK HELP也没查到,在哪里呢?
另外如何用,方便的话写个DEMO吧?
 
VerifyVersionInfo是Win2K以上OS才有的。
 
刚刚写了一个函数,拿去用就行了:[:)]
function GetWinVersionInfo: string;
type
OSVERSIONINFOEXA = record
dwOSVersionInfoSize: DWORD;
dwMajorVersion: DWORD;
dwMinorVersion: DWORD;
dwBuildNumber: DWORD;
dwPlatformId: DWORD;
szCSDVersion: array[0..127] of Char;
wServicePackMajor: Word;
wServicePackMinor: Word;
wSuiteMask: Word;
wProductType: Byte;
wReserved: Byte;
end;
TGetVersionExA = function(lpVersionInformation: POSVersionInfo): BOOL; stdcall;
const
VER_NT_WORKSTATION = $0000001;
VER_NT_SERVER = $0000003;
VER_SUITE_ENTERPRISE = $00000002;
VER_SUITE_DATACENTER = $00000080;
VER_SUITE_PERSONAL = $00000200;
var
GetVersionExA: TGetVersionExA;
OsVersionEx: OSVERSIONINFOEXA;
LibHandle: THandle;
AOsName: string;
bOsVersionInfoEx: Boolean;
FKey: hKey;
szProductType: string;
dwBufLen: DWORD;
begin
AOsName := 'Unknown Windows Version';
LibHandle := LoadLibrary(kernel32);
if LibHandle > 0 then
try
@GetVersionExA := GetProcAddress(LibHandle, 'GetVersionExA');
if @GetVersionExA <> nil then
begin
FillChar(OsVersionEx, SizeOf(OSVERSIONINFOEXA), 0);
OsVersionEx.dwOSVersionInfoSize := SizeOf(OSVERSIONINFOEXA);
bOsVersionInfoEx := GetVersionExA(POSVersionInfo(@OsVersionEx));
if not bOsVersionInfoEx then
begin
FillChar(OsVersionEx, SizeOf(TOSVersionInfo), 0);
OsVersionEx.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
if not GetVersionExA(POSVersionInfo(@OsVersionEx)) then
RaiseLastOSError;
end;
with OsVersionEx do
begin
case dwPlatformId of
VER_PLATFORM_WIN32_NT:
begin
if dwMajorVersion <= 4 then
AOsName := 'Microsoft Windows NT'
else if (dwMajorVersion = 5) and (dwMinorVersion = 0) then
AOsName := 'Microsoft Windows 2000'
else if (dwMajorVersion = 5) and (dwMinorVersion = 1) then
AOsName := 'Microsoft Windows XP';

if bOsVersionInfoEx then
begin
if wProductType = VER_NT_WORKSTATION then
begin
if wSuiteMask and VER_SUITE_PERSONAL = VER_SUITE_PERSONAL then
AOsName := AOsName + ' Personal'
else
AOsName := AOsName + ' Professional';
end
else if wProductType = VER_NT_SERVER then
begin
if (wSuiteMask and VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER then
AOsName := AOsName + ' DataCenter Server'
else if (wSuiteMask and VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE then
AOsName := AOsName + ' Advanced Server'
else
AOsName := AOsName + ' Server';
end;
end
else
begin
RegOpenKeyEx(HKEY_LOCAL_MACHINE, 'SYSTEM/CurrentControlSet/Control/ProductOptions',
0, KEY_QUERY_VALUE, FKey);
dwBufLen := 20;
SetLength(szProductType, dwBufLen);
RegQueryValueEx(FKey, 'ProductType', nil, nil, PByte(szProductType), @dwBufLen);
RegCloseKey(FKey);
SetLength(szProductType, dwBufLen);
if UpperCase(Trim(szProductType)) = 'WINNT' then
AOsName := AOsName + ' Workstation'
else if UpperCase(Trim(szProductType)) = 'SERVERNT' then
AOsName := AOsName + ' Server';
end;

if (dwMajorVersion <= 4) then
begin
AOsName := Format('%s Version %d.%d %s(Build %d)',
[AOsName, dwMajorVersion, dwMinorVersion, szCSDVersion,
dwBuildNumber and $FFFF]);
end
else
begin
AOsName := Format('%s %s(Build %d)', [AOsName, szCSDVersion,
dwBuildNumber and $FFFF]);
end;
end;
VER_PLATFORM_WIN32_WINDOWS:
begin
if (dwMajorVersion = 4) and (dwMinorVersion = 0) then
begin
AOsName := 'Microsoft Windows 95';
if (szCSDVersion[1] = 'C') then
AOsName := AOsName + ' OSR2';
end
else if (dwMajorVersion = 4) and (dwMinorVersion = 10) then
begin
AOsName := 'Microsoft Windows 98';
if szCSDVersion[1] = 'A' then
AOsName := AOsName + ' SE';
end
else if (dwMajorVersion = 4) and (dwMinorVersion = 90) then
begin
AOsName := 'Microsoft Windows Me';
end;
end;
VER_PLATFORM_WIN32s:
begin
AOsName := 'Microsoft Win32s';
end;
end;
end;
end;
finally
FreeLibrary(LibHandle);
end;
Result := AOsName;
end;
 
谢谢,
好象不能加分啊,看了半天,没找到....不象CSDN

等一下我再开一贴
 
请到此跟贴:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1249304
[:D]
 
后退
顶部