Solved

How I can get system resources status?

Posted on 2001-07-28
7
271 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 17

Accepted Solution

by:
inthe earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Listening :-)
0
 

Author Comment

by:totok
Comment Utility
Thank you for the answer. It works great!

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now