G
guojun
Unregistered / Unconfirmed
GUEST, unregistred user!
看了以前的讨论,是用如下方法(抄录如下),不知在Win2000下能否使用。
在Win2000下如何处理?我想知道系统资源状况,防止操作员无限制地开窗口。
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;
hInst16 : word;
Sr : Pointer;
begin
hInst16 := LoadLibrary16('user.exe');
Thunks[0] := hInst16;
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;
在Win2000下如何处理?我想知道系统资源状况,防止操作员无限制地开窗口。
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;
hInst16 : word;
Sr : Pointer;
begin
hInst16 := LoadLibrary16('user.exe');
Thunks[0] := hInst16;
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;