home *** CD-ROM | disk | FTP | other *** search
- program thunk;
-
- uses
- Windows, SysUtils;
-
- {$R *.RES}
-
- function LoadLibrary16 (lpLibFileName: PAnsiChar): HMODULE; stdcall;
- external kernel32 name '' index 35;
-
- function FreeLibrary16 (hLibModule: HMODULE): Bool; stdcall; stdcall;
- external kernel32 name '' index 36;
-
- function GetProcAddress16 (hModule: HMODULE; lpProcName: LPCSTR): FARPROC; stdcall;
- external kernel32 name '' index 37;
-
- procedure QT_Thunk;
- external kernel32;
-
- var
- hUser16: HModule;
- FSRProc: Pointer;
- UResult, GResult: Word;
- szBuff: array [0..255] of Char;
-
- procedure GetFSR;
- var
- ThunkJunk: array [0..127] of Char;
- begin
- ThunkJunk [0] := #0;
-
- hUser16 := LoadLibrary16 ('USER.EXE');
- if hUser16 < HModule (32) then Halt;
- FreeLibrary16 (hUser16);
- FSRProc := GetProcAddress16 (hUser16, 'GetFreeSystemResources');
- if FSRProc = Nil then Halt;
-
- { OK, we've got a 16:16 ptr to the wanted proc - now do the business... }
-
- asm
- push 1 // GFSR_GDIResources
- mov edx,FSRProc
- call QT_Thunk
- mov GResult,ax
-
- push 2 // GFSR_UserResources
- mov edx,FSRProc
- call QT_Thunk
- mov UResult,ax
- end;
- end;
-
- begin
- GetFSR;
- StrPCopy (szBuff, Format ('USER Resources = %d%%, GDI Resources = %d%%',
- [UResult, GResult]));
- MessageBox (0, szBuff, 'Thunk', mb_ok);
- end.
-