系统资源(100分)

  • 主题发起人 主题发起人 g622
  • 开始时间 开始时间
G

g622

Unregistered / Unconfirmed
GUEST, unregistred user!
在windows 98/nt中有性能这一页,中间有系统资源这一项,标出有多少资源可用,依据是什么,在delphi中如何得到?
 
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;
 
贴了半天才贴出来。
 
后退
顶部