![]() |
|
#1
|
||||
|
||||
|
The MMS Maker will only really make use of IsWin9x and IsWin2kOrGreater, but i updated some 5 year old code and added a bunch of snippets i found all around the web, changed them to suit the future and my coding. Main issues with ID'ing an OS by version number is after windows 2000 issues arise, Server 2003 and XP x64 share 5.2, Vista and Server 2008 Share version and build numbers. Code:
unit SystemInfo;
interface
uses Windows, SysUtils;
function GetServicePack: String;
function IsWin32s: Boolean;
function IsWin9x: Boolean;
function IsWinNT: Boolean;
function IsWin2kOrGreater: Boolean;
function IsWinXPOrGreater: Boolean;
function IsVistaOrGreater: Boolean;
function GetOSByName: String;
function GetOSByVersion: String;
//System Resource Info
function TotalPhysicalMemory: Int64; // Total physical memory in bytes.
function TotalPageMemory: Int64; //Total page file in bytes.
function AvailablePageMemory: Int64; //Page file left in bytes.
function AvailablePhysicalMemory: Int64; //Physical memory left in bytes.
function AvailableVirtualMemory: Int64; //Available virtual memory in bytes.
function MemoryUsedPercentage: Int64; //Total memory used in percentage (%)
function TotalVirtualMemory: Int64; //Total virtual memory in bytes.
implementation
function GetServicePack: String;
begin
if Win32CSDVersion > '' then
begin
Result := Win32CSDVersion;
end
else Result := 'No Service Pack';
end;
function IsWin32s: Boolean;
begin
Result := (Win32Platform = VER_PLATFORM_WIN32s);
end;
function IsWin9x: Boolean;
begin
Result := (Win32Platform = VER_PLATFORM_WIN32_WINDOWS);
end;
function IsWinNT: Boolean;
begin
Result := (Win32Platform = VER_PLATFORM_WIN32_NT);
end;
function IsWin2kOrGreater: Boolean;
begin
Result := (Win32MajorVersion >= 5) and (Win32Platform = VER_PLATFORM_WIN32_NT);
end;
function IsWinXPOrGreater: Boolean;
begin
Result := CheckWin32Version(5, 1);
end;
function IsVistaOrGreater: Boolean;
begin
Result := (Win32MajorVersion >= 6) and (Win32Platform = VER_PLATFORM_WIN32_NT);
end;
function GetOSByName: String;
begin
//Check for Win32s running on Windows 3.1, 3.11, 3.2
if Win32Platform = VER_PLATFORM_WIN32s then
begin
Result := 'Win32s on 3.x';
end;
//Check for Win9x based operating system
if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and (Win32MajorVersion = 4) then
begin
case Win32MinorVersion of
00: Result := '95';
03: Result := '95 OSR2';
10: if Win32BuildNumber = 2222 then
Result := '98SE'
else
Result := '98';
90: Result := 'ME';
else
Result := '9x OS';
end
end;
//Check for NT based operating system
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
case Win32MajorVersion of
4: Result := 'NT 4';
5: case Win32MinorVersion of
0: Result := '2000';
1: Result := 'XP';
2: Result := '2003 Server';
end;
6: case Win32MinorVersion of
0: Result := 'Vista';
end;
else
Result := 'NT OS';
end;
end;
end;
function GetOSByVersion: String;
begin
case Win32Platform of
1: Result := ('9X ' + (inttostr(Win32MajorVersion)) + '.'+ (inttostr(Win32MinorVersion)) + '.' + (inttostr(Win32BuildNumber)));
2: Result := ('NT ' + (inttostr(Win32MajorVersion)) + '.'+ (inttostr(Win32MinorVersion)) + '.' + (inttostr(Win32BuildNumber)));
end;
end;
function TotalPhysicalMemory: Int64;
var
MS: TMemoryStatus;
begin
MS.dwLength := SizeOf(MS);
GlobalMemoryStatus(MS);
result := MS.dwTotalPhys;
end;
function TotalPageMemory: Int64;
var
MS: TMemoryStatus;
begin
MS.dwLength := SizeOf(MS);
GlobalMemoryStatus(MS);
result := MS.dwTotalPageFile;
end;
function AvailablePageMemory: Int64;
var
MS: TMemoryStatus;
begin
MS.dwLength := SizeOf(MS);
GlobalMemoryStatus(MS);
result := MS.dwAvailPageFile;
end;
function AvailablePhysicalMemory: Int64;
var
MS: TMemoryStatus;
begin
MS.dwLength := SizeOf(MS);
GlobalMemoryStatus(MS);
result := MS.dwAvailPhys;
end;
function AvailableVirtualMemory: Int64;
var
MS: TMemoryStatus;
begin
MS.dwLength := SizeOf(MS);
GlobalMemoryStatus(MS);
result := MS.dwAvailVirtual;
end;
function MemoryUsedPercentage: Int64;
var
MS: TMemoryStatus;
begin
MS.dwLength := SizeOf(MS);
GlobalMemoryStatus(MS);
result := MS.dwMemoryLoad;
end;
function TotalVirtualMemory: Int64;
var
MS: TMemoryStatus;
begin
MS.dwLength := SizeOf(MS);
GlobalMemoryStatus(MS);
result := MS.dwTotalVirtual;
end;
initialization
finalization
end.
__________________
SOFTWARE: Rain's Simple MMS Maker | Rain's UltraLite MMS Makers TUTORIALS: PlayStation One on PSP Guide | UMD/ISO/CSO Guide | Recovery Flasher | FATMSMOD 3.71 on 4.01 | 4.05 Visualizer on 4.01
|
|
#2
|
||||
|
||||
|
now i need to learn pascal lol
__________________
PHAT(TA-086) & GOW Slim(TA-088v2) - firmware: 5.00M33-3 - addons: 1.50 addon(phat). Me: newbie programmer... Levone == pspjoke;
My Projects ignorance is forgivable.. stupidity is a sin i can never forgive. catch my latest projects at... |
![]() |
|
|
|||
|
|||
|
|
| Thread Tools | |
| Display Modes | |
|
|