function LoadLibrary16(LibraryName: PChar): THandle; stdcall; external kernel32 index 35;
procedure FreeLibrary16(HInstance: THandle); stdcall; external kernel32 index 36;
function GetProcAddress16(Hinstance: THandle; ProcName: PChar): Pointer; stdcall; external kernel32 index 37;
procedure QT_Thunk; cdecl; external kernel32 name 'QT_Thunk';
function GetFreeSysRes(SysRes: Word): Word;
var
Thunks: Array[0..$20] of Word;
begin
Thunks[0] := hInst16;
hInst16 := LoadLibrary16('user.exe');
if hInst16 < 32 then
raise Exception.Create('Can''t load USER.EXE!');
FreeLibrary16(hInst16);
SR := GetProcAddress16(hInst16, 'GetFreeSystemResources');
if SR = nil then
raise Exception.Create('Can''t get address of GetFreeSystemResources!');
asm
push SysRes // push arguments
mov edx, SR // load 16-bit procedure pointer
call QT_Thunk // call thunk
mov Result, ax // save the result
end;
end;
function TResMeter.GetSystemRes: Byte;
begin
Result := GetFreeSysRes(cSystemRes);
end;
function TResMeter.GetGDIRes: Byte;
begin
Result := GetFreeSysRes(cGDIRes);
end;
function TResMeter.GetUSERRes: Byte;
begin
Result := GetFreeSysRes(cUSERRes);
end;