2005. március 28., hétfő

How to get the free system resources


Problem/Question/Abstract:

How to get the free system resources

Answer:

unit Sysresources;

interface

uses
  Windows, Sysutils;

const
  GFSR_SYSTEMRESOURCES = 0;
  GFSR_GDIRESOURCES = 1;
  GFSR_USERRESOURCES = 2;

function GetSystemResources(typ: Word): Integer;

implementation

var
  hDll: HMODULE;
  pProc: function(typ: word): Integer; stdcall;

function GetSystemResources(typ: word): Integer;
begin
  result := pProc(typ);
end;

function InternalGetSystemresources(typ: Word): Integer; stdcall;
begin
  result := -1;
end;

initialization
  pProc := InternalGetSystemresources;
  if Win32Platform <> VER_PLATFORM_WIN32_NT then
  begin
    hdll := LoadLibrary('rsrc32.dll');
    if hdll <> 0 then
    begin
      @pProc := getProcAddress(hdll, '_MyGetFreeSystemResources32@4');
      if @pProc = nil then
        pProc := InternalGetSystemresources;
    end;
  end;
finalization
  if hDLL <> 0 then
    FreeLibrary(hdll);
end.

Nincsenek megjegyzések:

Megjegyzés küldése