Solved

System monitor

Posted on 2001-07-23
12
191 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
  • 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 263 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
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 video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

10 Experts available now in Live!

Get 1:1 Help Now