Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Система";
Текущий архив: 2002.10.31;
Скачать: [xml.tar.bz2];

Вниз

Определение версии операционки   Найти похожие ветки 

 
sukhanov   (2002-08-27 08:24) [0]

Вопрос: Как определить версию операционки?
Если использовать GetVersionEx то как определить что это
Windows 98 а не Windows 98 SE или
Windows 2000 Professional а не Windows 2000 Advanced Server?


 
Ученик   (2002-08-27 08:57) [1]

Из Project JEDI Code Library (JCL), компилироваться не будет много из JCL тащить надо, но идея, наверно, понятна

type
TWindowsVersion = (wvUnknown, wvWin95, wvWin95OSR2, wvWin98, wvWin98SE,
wvWinME, wvWinNT31, wvWinNT35, wvWinNT351, wvWinNT4, wvWin2000, wvWinXP);

TNtProductType = (ptUnknown, ptWorkStation, ptServer, ptAdvancedServer,
ptPersonal, ptProfessional, ptDatacenterServer);

type
TWindowsVersion = (wvUnknown, wvWin95, wvWin95OSR2, wvWin98, wvWin98SE,
wvWinME, wvWinNT31, wvWinNT35, wvWinNT351, wvWinNT4, wvWin2000, wvWinXP);

function GetWindowsVersion: TWindowsVersion;
begin
Result := wvUnknown;
case Win32Platform of
VER_PLATFORM_WIN32_WINDOWS:
case Win32MinorVersion of
0..9:
if Trim(Win32CSDVersion) = "B" then
Result := wvWin95OSR2
else
Result := wvWin95;
10..89:
// On Windows ME Win32MinorVersion can be 10 (indicating Windows 98
// under certain circumstances (image name is setup.exe). Checking
// the kernel version is one way of working around that.
{if KernelVersionHi = $0004005A then // 4.90.x.x
Result := wvWinME
else}
if Trim(Win32CSDVersion) = "A" then
Result := wvWin98SE
else
Result := wvWin98;
90:
Result := wvWinME;
end;
VER_PLATFORM_WIN32_NT:
case Win32MajorVersion of
3:
case Win32MinorVersion of
1:
Result := wvWinNT31;
5:
Result := wvWinNT35;
51:
Result := wvWinNT351;
end;
4:
Result := wvWinNT4;
5:
case Win32MinorVersion of
0:
Result := wvWin2000;
1:
Result := wvWinXP;
end;
end;
end;
end;

function NtProductType: TNtProductType;
const
ProductType = "System\CurrentControlSet\Control\ProductOptions";
var
Product: string;
VersionInfo: TOSVersionInfoEx;
begin
Result := ptUnknown;
FillChar(VersionInfo, SizeOf(VersionInfo), 0);
VersionInfo.dwOSVersionInfoSize := SizeOf(VersionInfo);

// Favor documented API over registry
if IsWinNT4 and (GetWindowsServicePackVersion >= 6) then
begin
if JclWin32.GetVersionEx(@VersionInfo) then
begin
if (VersionInfo.wProductType = VER_NT_WORKSTATION) then
Result := ptWorkstation
else
Result := ptServer;
end;
end
else
if IsWin2K then
begin
if JclWin32.GetVersionEx(@VersionInfo) then
begin
if (VersionInfo.wProductType = VER_NT_SERVER) then
begin
{ Changes by Scott Price on 11-Jan-2002 }
if (VersionInfo.wSuiteMask and VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER then
Result := ptDatacenterServer
{ Changes by Scott Price on 11-Jan-2002 }
else
if (VersionInfo.wSuiteMask and VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE then
Result := ptAdvancedServer
else
result := ptServer;
end
else
if (VersionInfo.wProductType = VER_NT_WORKSTATION) then
Result := ptProfessional;
end;
end
else
if IsWinXP then
begin
if JclWin32.GetVersionEx(@VersionInfo) then
begin
if (VersionInfo.wProductType = VER_NT_WORKSTATION) then
begin
{ Changes by Scott Price on 10-Jan-2002 }
if (VersionInfo.wSuiteMask and VER_SUITE_PERSONAL) = VER_SUITE_PERSONAL then
Result := ptPersonal
else
Result := ptProfessional;
end;
end;
end;

if Result = ptUnknown then
begin
// Non Windows 2000/XP system or the above method failed, try registry
{ Changes by Scott Price on 11-Jan-2002 }
Product := RegReadStringDef(HKEY_LOCAL_MACHINE, ProductType, "ProductType", "");
if CompareText(Product, "WINNT") = 0 then
Result := ptWorkStation
else
if CompareText(Product, "SERVERNT") = 0 then
Result := {ptServer} ptAdvancedServer
else
if CompareText(Product, "LANMANNT") = 0 then
Result := {ptAdvancedServer} ptServer
else
Result := ptUnknown;
end;

end;


 
SeB   (2002-08-27 11:44) [2]

Specifies the Win32 platform identifier.

Не знаю есть ли это в D4, но в D6 есть глобальная переменная
Win32Platform :

Win32Platform variable

Unit

SysUtils

Category

application-level information

extern PACKAGE int Win32Platform;

Description

Win32Platform is used to identify the type of Win32 platform the system is running. This will be one of the following values:

Value Meaning
VER_PLATFORM_WIN32s System is Win32s.
VER_PLATFORM_WIN32_WINDOWS System is Windows 95.
VER_PLATFORM_WIN32_NT System is Windows NT.



if (Win32Platform==VER_PLATFORM_WIN32s)
return false; //{Win32s? Quit!}

if (Win32Platform==VER_PLATFORM_WIN32_WINDOWS) { //{Win9X? Continue
:}
и т.д.


 
Джёпер   (2002-08-28 08:54) [3]

У меня стоит win 2k, а Win32Platform говорит что VER_PLATFORM_WIN32_WINDOWS как так.

Кстати Delphi 4


 
SeB   (2002-08-28 10:02) [4]

Я проверял под XP, 2000 и 98 - все нормально работает, под XP/NT выдает VER_PLATFORM_WIN32_NT, под 98 - VER_PLATFORM_WIN32_WINDOWS,
но у меня 6-й Builder, может D4 неправильно распознает систему?



Страницы: 1 вся ветка

Форум: "Система";
Текущий архив: 2002.10.31;
Скачать: [xml.tar.bz2];

Наверх




Память: 0.46 MB
Время: 0.037 c
6-101399
agafon
2002-08-28 09:56
2002.10.31
NMHTTP


1-101189
Kolya
2002-10-20 16:18
2002.10.31
ReadProcessMemory не хочет читать Memory


3-101125
Wetnose
2002-10-08 08:11
2002.10.31
ERWin и русский шрифт


4-101591
MJH
2002-09-15 06:07
2002.10.31
Каким макаром можно


1-101224
Ricks
2002-10-21 18:20
2002.10.31
Infinity





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский