Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to GetFreeSystemResources in Delphi3 ?

Posted on 1998-08-27
13
Medium Priority
?
516 Views
Last Modified: 2011-10-03
in delphi 1 there was a WinAPI-function available called GetFreeSystemResources. is there any WinAPI 32- function for delphi 3 to get the percentage of used/free system resource?

or any other possibility?

tia, Black Death.
0
Comment
Question by:BlackDeath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 1

Author Comment

by:BlackDeath
ID: 1337897
Edited text of question
0
 
LVL 1

Author Comment

by:BlackDeath
ID: 1337898
Edited text of question
0
 
LVL 5

Expert Comment

by:inter
ID: 1337899
Hi,
The basic function is GlobalMemoryStatus, seek it from win32 help...If not enough just ask...
Regards, Igor
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:BlackDeath
ID: 1337900
Hoi, Igor!

i already use GlobalMemoryStatus for my project system information object. this is not what i need.

problem is:
GlobalMemoryStatus only provides information on memory status.

with GetFreeSystemResources you could get info on
-system resources (GFSR_SYSTEMRESOURCES) {= memory status}
-gdi resources    (GFSR_GDIRESOURCES)
-user resources   (GFSR_USERRESOURCES)

have you got something for these?

regs,
Black Death
0
 
LVL 5

Expert Comment

by:inter
ID: 1337901
Hi,
I have NT and browse through the KERNEL32, GDI32 and USER32 DLL's upon our conversation but could not find that kind of specific function in either of then rather than GetSystemInfo in kernel32. Did you see such 32 bit program that gives these information. Because on my win nt even ShellAbout gives only memory status...
Regards, Igor (there is another way, we may make thunking with 16 bit KERNEL DLL and you can call your funciton, however in that case it gives a virtual information amoung 16 bit processes which is not through in 32 bit subsystem...)
Regards, Igor
0
 
LVL 1

Author Comment

by:BlackDeath
ID: 1337902
igor -

resource meter (95), for example, provides you with information on these 3 different resource usage values. i dunno if it is available on nt, but i guess so. on 95, it is rsrcmtr.exe, and it is a 32bit-app...

.which i've browsed just now and found that it's using rsrc32.dll which exports
_MyGetFreeSystemResources32@4
thk_ThunkData32
and imports
KERNEL32.dll - ThunkConnect32

so, i guess your guess is what's to be guessed. (argh)

are you capable of implementing a thunking layer?

regs,

Black Death.
0
 
LVL 5

Expert Comment

by:inter
ID: 1337903
Hi,
There is a way for win32 on win95 but i am sorry for NT... It is called flat thunking and 4 undocumented functions exported from Kernel32 are used...Interested?
Regarsd, Igor
0
 
LVL 1

Author Comment

by:BlackDeath
ID: 1337904
mais oui, mon ami.

Black Death.
0
 
LVL 5

Expert Comment

by:inter
ID: 1337905
Hi, again,
The following is exactly what you want I think (if we are luckey, you did not even write single line of code). Any way make the following a seperate unit and call your GetFreeSystemResources with either 0,1, or 2

//***********************
// CODE STARTS
unit FreeRes;

{ Get free system resources in Windows 95.
  For reasons unknown outside of Microsoft, the Win32 API
  does not define the GetFreeSystemResources function.
  The only way to get this information is to call a 16-bit
  function in USER.EXE. You can try messing around with thunking,
  but there's an easier way in Windows 95. (I don't know how
  to do this in NT, though.)

  This information comes from "Windows 95 System Programming Secrets"
  by Matt Pietrek.

  This unit provides the GetFreeSystemResources function
  for Windows 95. See the Windows 3.1 API documentation
  to learn more about this function.

  Copyright © 1996 Tempest Software

  You may use this software as part of an application program
  without fee or royalty. Use this software at your own risk.
  As free software, it is offered without guarantee.
}

interface

const
  Gfsr_SystemResources = 0;
  Gfsr_GdiResources = 1;
  Gfsr_UserResources = 2;

function GetFreeSystemResources(SysResource: Word): Word;

implementation

uses SysUtils, Windows;

{ Undocumented Kernel32 calls. }
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
  { 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;

end.
// CODE ENDS
//***********************
Regards, Igor


0
 
LVL 5

Expert Comment

by:inter
ID: 1337906
Sorry,
I did not remember where I have learnt the Qthunking. Strangely, that comes up just what we want when I dig in to my code repository. So, I did not intentionally delay the solution,
excuse me,
Igor
0
 
LVL 1

Author Comment

by:BlackDeath
ID: 1337907
igor - it works.

please post an answer so i can award you.

thanxalot,

Black Death.
0
 
LVL 5

Accepted Solution

by:
inter earned 120 total points
ID: 1337908
I am glad that it works,
Cheers, Igor; - )
0
 
LVL 1

Author Comment

by:BlackDeath
ID: 1337909
me, too! thanxagain&bye,
Black.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question