Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

System monitor

Posted on 2001-07-23
12
Medium Priority
?
214 Views
Last Modified: 2010-04-06
Hi.
I have to make a program to monitor in real-time the resources of memory, disk, processors,...

I have to know which APIs do i have to use and if they work in win32.
Thanks
0
Comment
Question by:pepe2000
[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
  • 9
  • 3
12 Comments
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6311264
for memory : ( in windows unit ) :
GlobalMemoryStatus(var lpBuffer: TMemoryStatus); stdcall;

for disk : ( in sysutils unit ) :
disksize & diskfree

for processor : ( in windows Unit ):
getsysteminfo()

although i have never used them ( just use DiskFree )

best regards
hamed
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6311270
for memory : ( in windows unit ) :
GlobalMemoryStatus(var lpBuffer: TMemoryStatus); stdcall;

for disk : ( in sysutils unit ) :
disksize & diskfree

for processor : ( in windows Unit ):
getsysteminfo()

although i have never used them ( just use DiskFree )

best regards
hamed
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6311274
i think if u search windows Unit u can find better func. or proc.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6311920
u can also see win32.hlp for find a good API. ( it was recommended by inthe and i saw it in API problem - 3 q after ur q )
0
 

Author Comment

by:pepe2000
ID: 6312873
Can i make a real time analysis drawing changes second by second with that?

does it work in win32?
How do i call an api function in Delphi? i know how to do it in VB
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6313563
windows API func. and proc. are maped to Delphi by windows unit. ( see the source in Source folder ) if u type 'windows.' a popup menu opens that shows u all of the func. that API has.

if u see windows unit u can see that all of the functions are derived from dlls that are windows API.

for refreshing ur monitor use a Ttimer ( in system folder ) and set the interval ( in ms ) that u want then duble click on the Timer component u can set the ontimer procedure and in that proc. u can write ur monitor code.

the timer is used in exact form that u use in VB.

best regards
hamed
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6313577
u must refresh the page second by second.the timing is prepared by timer.
0
 

Author Comment

by:pepe2000
ID: 6314020
the only new thing i learned from this question is that i can call windows api with 'windows.'

i dont think it worth 263 points so maybe you can help me with the functions that i can use to monitor the system, i want to know the parameters, and then i accept the answer.
Thanks


0
 
LVL 1

Accepted Solution

by:
h_mohsenian earned 1052 total points
ID: 6316281
i just wanted to help u as one of my friends.point is not important for me.i felt u are alittle hard with me. but i always try to be so kindly & friendly with other experts. and I have some friends just in more that 3 weeks using this site ( i signed up last year but never came back until about 3 or 4 weeks ago ).
also we can be friend ( even good friends )with each other.

and i wana told u another point that if u think i suggested u little new learning it is not becouse of that i did not want to tell u more, just I think they can be enouph for u and as i said i didnt use aother APIs that i suggested u.i told it as comment ( not aswer )

anyway about ur q again :
 at the follow i just talk about that i tested ;-)

1. for get memory info :
// GlobalMemoryStatus(var lpBuffer: TMemoryStatus);

(* it is form win32.hlp
  typedef struct _MEMORYSTATUS { // mst  
    DWORD dwLength;        // sizeof(MEMORYSTATUS)
    DWORD dwMemoryLoad;    // percent of memory in use
    DWORD dwTotalPhys;     // bytes of physical memory
    DWORD dwAvailPhys;     // free physical memory bytes
    DWORD dwTotalPageFile; // bytes of paging file
    DWORD dwAvailPageFile; // free bytes of paging file
    DWORD dwTotalVirtual;  // user bytes of address space
    DWORD dwAvailVirtual;  // free user bytes

} MEMORYSTATUS, *LPMEMORYSTATUS;  *)


procedure TForm1.Button1Click(Sender: TObject);
var lpBuffer: TMemoryStatus;
begin
GlobalMemoryStatus(lpBuffer);
edit1.text := inttostr(lpBuffer.dwLength); // size in MB
edit2.text := inttostr(lpBuffer.dwMemoryLoad);
edit3.text := inttostr(lpBuffer.dwTotalPhys);// size in byte
edit4.text := inttostr(lpBuffer.dwAvailPhys);
edit5.text := inttostr(lpBuffer.dwTotalPageFile);
edit6.text := inttostr(lpBuffer.dwAvailPageFile);
edit7.text := inttostr(lpBuffer.dwTotalVirtual);
edit8.text := inttostr(lpBuffer.dwAvailVirtual);
// i think it that is good for monitor Memory Status
end;

2. for power supply :
//SYSTEM_POWER_STATUS
//GetSystemPowerStatus
also it is not so important for u.

3.for system status :

(* it is form win32.hlp
typedef struct _SYSTEM_INFO { // sinf  
    union {
        DWORD  dwOemId;
        struct {
            WORD wProcessorArchitecture;
            WORD wReserved;
        };
    };
    DWORD  dwPageSize;
    LPVOID lpMinimumApplicationAddress;
    LPVOID lpMaximumApplicationAddress;
    DWORD  dwActiveProcessorMask;
    DWORD  dwNumberOfProcessors;
    DWORD  dwProcessorType;
    DWORD  dwAllocationGranularity;
    WORD  wProcessorLevel;
    WORD  wProcessorRevision;

} SYSTEM_INFO;  *)

procedure TForm1.Button1Click(Sender: TObject);
var lpSystemInfo: TSystemInfo;
begin
GetSystemInfo(lpSystemInfo);
case lpSystemInfo.wProcessorArchitecture of
     0 : Edit1.Text  := 'PROCESSOR_ARCHITECTURE_INTEL';
     {Windows NT only: i dont now the exact value }
     1 : Edit1.Text  := 'PROCESSOR_ARCHITECTURE_MIPS';
     2 : Edit1.Text  := 'PROCESSOR_ARCHITECTURE_ALPHA';
     3 : Edit1.Text  := 'PROCESSOR_ARCHITECTURE_PPC';
     4 : Edit1.Text  := 'PROCESSOR_ARCHITECTURE_UNKNOWN';
     end; // Case

edit2.text := inttostr(lpSystemInfo.dwPageSize);
edit3.text := inttostr(lpSystemInfo.dwNumberOfProcessors);
case lpSystemInfo.dwProcessorType of
386 : Edit4.Text := 'PROCESSOR_INTEL_386';
486 : Edit4.Text := 'PROCESSOR_INTEL_486';
586 : Edit4.Text := 'PROCESSOR_INTEL_PENTIUM';
end; // case

//
//  ... for other info
//


end;

4. Disk ( use sysutiles )

//DiskFree returns the number of free bytes on the specified drive, where 0 = Current, 1 = A, 2 = B, and so on.
//DiskFree returns -1 if the drive number is invalid.

procedure TForm1.Button1Click(Sender: TObject);
begin
  // i used it for current Drive
  edit1.text := Inttostr(Disksize(0));
  edit2.text := Inttostr(Diskfree(0));
  // u cas monitor all of the drives
end;


i hope that codes can help u.
if u want at the next comment tell more about yourself.

best regards
hamed:-)
0
 

Author Comment

by:pepe2000
ID: 6317525
Im very sorry hamed!

Im from Argentina and my english is not so full of words to tell what i feel
Anyway i didnt want to give the feeling that you felt about me.
This site helps me a lot and i only have good words to all the users that helps to the others
Thanks again

by the way, My name is Ariel and im 22 years old programmer.
I prefer to use Visual Basic but i have to do this a homework in Delphi for the University.
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6321148
dear Arial,

no worries,Now I feel we can be the best friends in Ex-Ex site.I am glad that my comment could help u.
is it enouph for ur homework?

anyway, I am Iranian and 22 years old ( exactly 22.4 ), I am a senior student of Electrical Control Eng. I passed my courses nearly and now i am working on my BS project ('Design a PC-based DCS Automation System for a Textile Factory').
I started windows programming by VB3 at win16 but when I saw Delphi I fell in love with Delphi ;-) I am pleased to be friend with u.

thanks for ur Answer point , but i think it is much more than my comment value.ur kindly replying was enouph and more interesting for me;-).I am sure that now we are friends. I am worry about ur future q, if u have not enouph q point for askintg q ,send ur question(q) to me , i will ask ur q instead of u ;-)

my email is :
mohsenianrad@scribe.com
&
h_mohsenian@yahoo.com ( it is better )

tell me more about urself, and ur university ( is this homework for university course ?)

best regards
hamed;-)
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6329809
Ariel , are you here!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

705 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