Tech Support > Operating Systems > Windows 95 > resources
resources
Posted by Otto Slembeck on May 13th, 2004


I use the following code in a program to check if the computer has
sufficient resources to open an external wordprocessor:

#define GFSR_SYSTEMRESOURCES 0
#define GFSR_GDIResOURCES 1
#define GFSR_USERRESOURCES 2
static SystemRes=0, UserRes=0, GDIRes=0
if type('GetFreeSystemResources') # 'FP'
extern cint GetFreeSystemResources(cint) rsrc32.dll from
'_MyGetFreeSystemResources32@4'
endif
mSystemRes = GetFreeSystemResources( GFSR_SYSTEMRESOURCES )
mGDIRes = GetFreeSystemResources( GFSR_GDIResOURCES )
mUserRes = GetFreeSystemResources( GFSR_USERRESOURCES )

This works fine when running under Windows ME. Windows 98 does not have the
file 'rsrc32.dll'.
Is there an equivalent file or a different code that works under ALL Windows
operating systems?


TIA
Otto




Posted by Bart on May 14th, 2004


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)

Posted by Isaac on May 17th, 2004


"Otto Slembeck" <otto_slembeck@rogers.com> wrote in
news:OT4WqJTOEHA.556@tk2msftngp13.phx.gbl:

You can use GlobalMemoryStatus.




Similar Posts