var
Form1: TForm1;
function GetOS :TOSVersion;
implementation
{$R *.DFM}
function GetOS;
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: Result:=os2K;
end;
if (OS.dwMajorVersion=5) and (OS.dwMinorVersion=1) then
Result:=osXP;
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;
switch (osvi.dwPlatformId)
{
// Tests for Windows NT product family.
case VER_PLATFORM_WIN32_NT:
// Test for the product.
if ( osvi.dwMajorVersion <= 4 )
printf("Microsoft Windows NT ");
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
printf ("Microsoft Windows 2000 ");
if( bOsVersionInfoEx ) // Use information from GetVersionEx.
{
// Test for the workstation type.
if ( osvi.wProductType == VER_NT_WORKSTATION )
{
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
printf ("Microsoft Windows XP ");
// Test for the server type.
else if ( osvi.wProductType == VER_NT_SERVER )
{
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
printf ("Microsoft Windows .NET ");
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
printf ( "DataCenter Server " );
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
if( osvi.dwMajorVersion == 4 )
printf ("Advanced Server " );
else
printf ( "Enterprise Server " );
else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
printf ( "Web Server " );
else
printf ( "Server " );
}
}
else // Use the registry on early versions of Windows NT.
{
HKEY hKey;
char szProductType[80];
DWORD dwBufLen;
내 컴퓨터에 마우스 오른쪽 버튼을 누르고 등록정보를 열면 오른쪽 위에 시스템: Microsoft Windows 2000 5.00.2195 이하 쭉~~~~ 이라고 뜨는데 버젼과 빌드는 구하는 예가 많아서 알겠는데, 현재 OS가 Microsoft Windows 2000이라는 이름...
홍성락
•
2002.04.04 03:17
hsr//////////////////////////////////////////////////////////////
unit Unit1;
interface
use...
우영범
•
2002.04.04 02:56
msdn에 있는 샘플입니다.
델파이로 변환해서 사용하십시오.
BOOL DisplaySystemVersion()
...
hsr//////////////////////////////////////////////////////////////
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TOSVersion = (osUnknown, os95, os95OSR2, os98, os98SE, osNT3, osNT4, os2K, osME, osXP);
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
function GetOS :TOSVersion;
implementation
{$R *.DFM}
function GetOS;
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: Result:=os2K;
end;
if (OS.dwMajorVersion=5) and (OS.dwMinorVersion=1) then
Result:=osXP;
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;
procedure TForm1.Button1Click(Sender: TObject);
var
OSVersion :string;
begin
case GetOS of
os95, os95OSR2 : OSVersion:='Windows 95';
os98, os98SE : OSVersion:='Windows 98';
osME : OSVersion:='Windows Millenium Edition';
osNT3, osNT4 : OSVersion:='Windows NT';
os2K : OSVersion:='Windows 2000';
osXP : OSVersion:='Windows XP';
end;
showmessage(OSVersion);
end;
end.