u_sysinfo.pas

来自「漏洞扫描系列中HB Network Scanner 测试用练习代码」· PAS 代码 · 共 53 行

PAS
53
字号
unit u_SysInfo;


interface

uses
  Windows;

function GetSwapFileUsage: Integer;
function GetMemoryLoad: Byte;
function getPlatformId : DWORD;

implementation

// Returns the percentage of swap file space occupied. This is a value between 0 and 100.
function GetSwapFileUsage: Integer;
var
  MemoryStatus: TMemoryStatus;
begin
  FillChar(MemoryStatus, SizeOf(MemoryStatus), 0);
  MemoryStatus.dwLength := SizeOf(MemoryStatus);
  GlobalMemoryStatus(MemoryStatus);
  with MemoryStatus do
    Result := 100 - Trunc(dwAvailPageFile / dwTotalPageFile * 100);
end;

// This function returns the current system memory load. The result is a value between 0 and 100.
function GetMemoryLoad: Byte;
var
  MemoryStatus: TMemoryStatus;
begin
  FillChar(MemoryStatus, SizeOf(MemoryStatus), 0);
  MemoryStatus.dwLength := SizeOf(MemoryStatus);
  GlobalMemoryStatus(MemoryStatus);
  Result := MemoryStatus.dwMemoryLoad;
end;

// this function does not come from JCL
// returns VER_PLATFORM_WIN32_WINDOWS (95,98,Me)
// or      VER_PLATFORM_WIN32_NT (NT,2000)
function getPlatformId : DWORD;
var
  l_info : OSVERSIONINFO;
begin
  // on d閠ermine quelle est la version de windows utilis閑
  l_info.dwOSVersionInfoSize := Sizeof(OSVERSIONINFO);
  GetVersionEx(l_Info);
  result := l_Info.dwPlatformId;
end;


end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?