Solved

System monitor

Posted on 2001-07-23
12
194 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 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