Op Thu, 13 May 2004 17:36:37 -0400 schreef "Otto Slembeck"
<otto_slembeck@rogers.com>:
In 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';
{ Use global variables, so QT_Thunk does not trash them. }
var
hInst16: THandle;
GFSR: Pointer;
{ QT_Thunk needs a stack frame. }
{$StackFrames On}
{ Thunking call to 16-bit USER.EXE. The ThunkTrash argument
allocates space on the stack for QT_Thunk. }
function GetFreeSystemResources(SysResource: Word): Word;
var
ThunkTrash: array[0..$20] of Word;
begin
{ Controlla che non siamo sotto NT }
if Win32Platform = VER_PLATFORM_WIN32_NT then begin
Result := 400;
Exit;
end;
{ Prevent the optimizer from getting rid of ThunkTrash. }
ThunkTrash[0] := hInst16;
hInst16 := LoadLibrary16('user.exe');
if hInst16 < 32 then
raise Exception.Create('Cannot load USER.EXE');
{ Decrement the usage count. This doesn't really free the
library, since USER.EXE is always loaded. }
FreeLibrary16(hInst16);
{ Get the function pointer for the 16-bit function in USER.EXE. }
GFSR := GetProcAddress16(hInst16, 'GetFreeSystemResources');
if GFSR = nil then
raise Exception.Create('Cannot get address of
GetFreeSystemResources');
{ Thunk down to USER.EXE. }
asm
push SysResource { push arguments }
mov edx, GFSR { load 16-bit procedure pointer }
call QT_Thunk { call thunk }
mov Result, ax { save the result }
end;
end;
ONGETEST !
BRON:
=================//
// Studio CIRCUS //
//=================
home : http://www.geocities.com/Paris/Metro/4020/
----------------------------------/
/ TscSysInfo v.1.3 - Feb, 02 1998 /
/----------------------------------
Groetjes,
Bart
--
Bart Broersma
broersma.juda_ANTISPAM_@tiscali.nl
(ff _ANTISPAM_ wegpoetsen uit dit adres natuurlijk)