如何获得当前系统资源使用状况的信息???(50分)

  • 主题发起人 主题发起人 nuke
  • 开始时间 开始时间
N

nuke

Unregistered / Unconfirmed
GUEST, unregistred user!
就象win98的"资源状况:一样把当前资源状况用百分比表示出来。
 
试试这个程序段:
var
x,y:integer;

sysinfo:Tsysteminfo;

meminfo:Tmemorystatus;
c2,c3,c4,c5:integer;
begin
getsysteminfo(sysinfo);
label16.caption:=inttostr(sysinfo.dwProcessorType);
x:=getsystemmetrics(0);
y:=getsystemmetrics(1);
label17.caption:=inttostr(x)+'*'+inttostr(y);
globalmemorystatus(meminfo);
label11.caption:=inttostr(meminfo.dwTotalPhys)+'字节';
label19.caption:=inttostr(meminfo.dwAvailPhys)+'字节';
label12.caption:=inttostr(meminfo.dwTotalVirtual)+'字节';
label13.caption:=inttostr(meminfo.dwAvailVirTual)+'字节';
getdiskfreespace('c:/',c2,c3,c4,c5);
label14.caption:=inttostr(c5*c2*c3)+'字节';
label15.caption:=inttostr(c4*c2*c3)+'字节';
end;
 
不好意思,刚才瞎抄抄错了,以下是一个正确的:(也是抄的。) //shy
procedure TForm1.Button1Click(Sender: TObject);
var
MemoryStatus: TMemoryStatus;
begin
Memo1.Lines.Clear;
MemoryStatus.dwLength := SizeOf(MemoryStatus);
// !!!
GlobalMemoryStatus(MemoryStatus);
with MemoryStatusdo
begin
// Size of MemoryStatus record
Memo1.Lines.Add(IntToStr(dwLength) +
' Size of ''MemoryStatus'' record');
// Per-Cent of Memory in use by your system
Memo1.Lines.Add(IntToStr(dwMemoryLoad) +
'% memory in use');
// The amount of Total Physical memory allocated to your system.
Memo1.Lines.Add(IntToStr(dwTotalPhys) +
' Total Physical Memory in bytes');
// The amount available of physical memory in your system.
Memo1.Lines.Add(IntToStr(dwAvailPhys) +
' Available Physical Memory in bytes');
// The amount of Total Bytes allocated to your page file.
Memo1.Lines.Add(IntToStr(dwTotalPageFile) +
' Total Bytes of Paging File');
// The amount of available bytes in your page file.
Memo1.Lines.Add(IntToStr(dwAvailPageFile) +
' Available bytes in paging file');
// The amount of Total bytes allocated to this program
// (generally 2 gigabytes of virtual space).
Memo1.Lines.Add(IntToStr(dwTotalVirtual) +
' User Bytes of Address space');
// The amount of avalable bytes that is left to your program to use.
Memo1.Lines.Add(IntToStr(dwAvailVirtual) +
' Available User bytes of address space');
end;
// with
end;
// procedure
 
柳五你发财了哦!
分赃五十元!!
 
后退
顶部