Solved

How I can get system resources status?

Posted on 2001-07-28
7
280 Views
Last Modified: 2010-04-06
Hi,

How I can get system resources status (GDI,System, User) in Windows 9x ?

Is it possible to get system resources status in Windows 2000?

Thank you for your help.
0
Comment
Question by:totok
7 Comments
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6330646
No matter what Win 2000 always returns 90% because Win 2000 and NT and XP have pretty much virtually eliminated System Resources.

For Win 9x take a look at this KB from MS. Although it was written for VB it still has some very useful info. One of which there is not any direct 32bit call to the system that can be made to get this info from a 32bit application.

http://support.microsoft.com/support/kb/articles/Q190/2/17.ASP 



The Crazy One
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6330664
If you have a 16bit version of Delphi then you could use the GetFreeSystemResources 16bit API to get the info.

Also you take a look at this link.
http://support.microsoft.com/support/kb/articles/Q155/7/63.ASP
0
 
LVL 21

Expert Comment

by:gemarti
ID: 6331083
GetCommandLine() retrieves the command line used to launch your application.

GetComputerName() retrieves the network computer name.

GetDiskFreeSpace()retrieves information on free disk space.

GetDriveType() retrieves a specified drive type, such as fixed or removable.

GetLocalInfo() retrieves information on the specified locale.

GetLocalTime() retrieves the local time.

GetLogicalDrives() retrieves the drives available to the machine.

GetLogicalDriveStrings() Retrieves the names of the drives available to the machine.

GetStartupInfo() retrieves the startup information for the applications main window.

GetSystemDefaultLangID() retrieves the system default language identifier.

GetSystemDefaultLCID() retrieves the system default locale identifier.

GetSystemDirectory() retrieves the Windows system directory.

GetSystemInfo() retrieves system hardware information.

GetSystemTime() retrieves the current system time.

GetSystemTimeAsFileTime() retrieves the current system time in a file system time format.

GetTimeZoneInformation() retrieves time zone information concerning standard and daylight savings time.

GetUserDefaultLangID() retrieves the user defined default language identifier.

GetUserDefaultCID() retrieves the user defined default local identifier.

GetUSerName()retrieves the logged on network user name.

GetVersionEx() retrieves the windows version.

GetVolumeInformation() retrieves information on the specified volume.


Hope this helps you narrow down what your search.


GEM

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 17

Accepted Solution

by:
inthe earned 100 total points
ID: 6331671
below is how to do it under win9*
it is no where near the same for win2k/nt based systems as they no longer use resources as they did in win9*.they uses the performace monitering apis instead examples can be found at:
http://www.wilsonc.demon.co.uk/delphi_5.htm
see procesviewer demo.

and
ftp://delphi-jedi.org/api/PerfMon.zip
which is an "Interface for Microsoft Windows Performance Monitoring, v.1.2"
can be difficult stuff to get to grips with ;-)


anyway for win9*:


unit Thunker;

interface

const
  SYSres    = 0;
  USERres   = 2;
  GDIres    = 1;

function GetSystemResources(Res: Word): Word;
function UserPercentage : Integer;
function SystemPercentage : Integer;
function GDIPercentage : Integer;
procedure DisplayFreeResources;


implementation

uses Windows,SysUtils,Dialogs;

function ThunkLoadLibrary(LibraryName: PChar): THandle; stdcall; external kernel32 index 35;
procedure ThunkFreeLibrary(HInstance: THandle); stdcall; external kernel32 index 36;
function ThunkGetProcAddress(Hinstance: THandle; ProcName: PChar): Pointer; stdcall; external kernel32 index 37;
procedure Thunk; cdecl; external kernel32 name 'QT_Thunk';

{$StackFrames On}

var
  Th : THandle = 0;
  P: Pointer = nil;

function GetSystemResources(Res: Word): Word;
var
  Ar : array[0..$40] of Word;
begin
  Ar[0] := Th; //get major error without this ?
  Th := ThunkLoadLibrary('user.exe');
  if Th < 32 then
    raise Exception.Create('Error loading User.exe');
   ThunkFreeLibrary(Th);
  P := ThunkGetProcAddress(Th,'GetFreeSystemResources');
  if P = nil then
    raise Exception.Create('GetSystemResources function not found');
   asm
    push Res
    mov edx, P
    call Thunk
    mov Result, ax
  end;
end;

function UserPercentage : Integer;
 begin
  Result := GetSystemResources(USERres);
 end;

function SystemPercentage : Integer;
 begin
  Result := GetSystemResources(SYSres);
 end;

function GDIPercentage : Integer;
 begin
  Result := GetSystemResources(GDIres);
 end;

Procedure DisplayFreeResources;
begin
showmessage(
'SYSTEM : '+inttostr(SystemPercentage)+'%'+#13#10+
'USER : '+inttostr(UserPercentage)+'%'+#13#10+
'GDI : '+inttostr(GDIPercentage)+'%');
end;

end.



example of using:

gdi,sys and user are tprogressbars

uses Thunker;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
gdi.Position := GDIPercentage;
sys.position := SystemPercentage;
user.position := UserPercentage;
gdi.hint := inttostr(GDIPercentage)+'%';
sys.hint := inttostr(SystemPercentage)+'%';
user.hint := inttostr(UserPercentage)+'%';
Form1.Caption := '   Gdi : '+inttostr(GDIPercentage)+'%'+
'   System : '+inttostr(SystemPercentage)+'%'+
'   User : '+inttostr(UserPercentage)+'%';
end;



Regards Barry
0
 
LVL 3

Expert Comment

by:lopem
ID: 6331895
Here is a component I found some time ago, Hope this helps...

best regards,
Manuel Lopez (lopem)

{*************************************************************}
{            ResMeter Component for Delphi 32                 }
{ Version:   1.0                                              }
{ Author:    Aleksey Kuznetsov                                }
{ E-Mail:    info@utilmind.com                                }
{ Home Page: http://www.utilmind.com                          }
{ Created:   June, 30, 1999                                   }
{ Modified:  June, 30, 1999                                   }
{ Legal:     Copyright (c) 1999, UtilMind Solutions           }
{*************************************************************}
{ PROPERTIES:                                                 }
{   ResSystem: Byte - Determines the system resources in %    }
{   ResGDI: Byte - Determines the GDI resources in percents   }
{   ResUSER: Byte - Determines the USER resources in percents }
{*************************************************************}
{                     IMPORTANT NOTE:                         }
{ This software is provided 'as-is', without any express or   }
{ implied warranty. In no event will the author be held       }
{ liable for any damages arising from the use of this         }
{ software.                                                   }
{ Permission is granted to anyone to use this software for    }
{ any purpose, including commercial applications, and to      }
{ alter it and redistribute it freely, subject to the         }
{ following restrictions:                                     }
{ 1. The origin of this software must not be misrepresented,  }
{    you must not claim that you wrote the original software. }
{    If you use this software in a product, an acknowledgment }
{    in the product documentation would be appreciated but is }
{    not required.                                            }
{ 2. Altered source versions must be plainly marked as such,  }
{    and must not be misrepresented as being the original     }
{    software.                                                }
{ 3. This notice may not be removed or altered from any       }
{    source distribution.                                     }
{*************************************************************}

unit ResMeter;

interface

uses
  SysUtils, Windows, Classes, Controls, Forms;

type
  TResMeter = class(TComponent)
  private
    function GetSystemRes: Byte;
    function GetGDIRes: Byte;
    function GetUSERRes: Byte;
    procedure SetNone(Value: Byte);
  protected
  public
  published
    property ResSystem: Byte read GetSystemRes write SetNone;
    property ResGDI: Byte read GetGDIRes write SetNone;
    property ResUser: Byte read GetUserRes write SetNone;
  end;

procedure Register;

implementation

const
  cSystemRes = 0;
  cGDIRes = 1;
  cUSERRes = 2;

var
  hInst16: THandle;
  SR: Pointer;

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;
begin
  Thunks[0] := hInst16;
  hInst16 := LoadLibrary16('user.exe');
  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;

function TResMeter.GetSystemRes: Byte;
begin
  Result := GetFreeSysRes(cSystemRes);
end;

function TResMeter.GetGDIRes: Byte;
begin
  Result := GetFreeSysRes(cGDIRes);
end;

function TResMeter.GetUSERRes: Byte;
begin
  Result := GetFreeSysRes(cUSERRes);
end;

procedure TResMeter.SetNone(Value: Byte);
begin
end;

procedure Register;
begin
  RegisterComponents('UtilMind', [TResMeter]);
end;

end.
0
 
LVL 5

Expert Comment

by:Gwena
ID: 6332040
Listening :-)
0
 

Author Comment

by:totok
ID: 6339315
Thank you for the answer. It works great!

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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