Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

System monitor

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
pepe2000
Asked:
pepe2000
  • 9
  • 3
1 Solution
 
h_mohsenianCommented:
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
 
h_mohsenianCommented:
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
 
h_mohsenianCommented:
i think if u search windows Unit u can find better func. or proc.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
h_mohsenianCommented:
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
 
pepe2000Author Commented:
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
 
h_mohsenianCommented:
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
 
h_mohsenianCommented:
u must refresh the page second by second.the timing is prepared by timer.
0
 
pepe2000Author Commented:
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
 
h_mohsenianCommented:
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
 
pepe2000Author Commented:
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
 
h_mohsenianCommented:
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
 
h_mohsenianCommented:
Ariel , are you here!
0

Featured Post

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.

  • 9
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now