Code
- [COLOR=#0000af][B]unit[/B][/COLOR] Unit1;
- [COLOR=#0000af][B]interface[/B][/COLOR]
- [COLOR=#0000af][B]uses[/B][/COLOR]
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, Gauges, Registry, ComCtrls, ExtCtrls;
- [COLOR=#0000af][B]type[/B][/COLOR]
- TForm1 [COLOR=#0000af]=[/COLOR] [COLOR=#0000af][B]class[/B][/COLOR](TForm)
- ListBox1: TListBox;
- Label1: TLabel;
- Label2: TLabel;
- Gauge1: TGauge;
- Gauge2: TGauge;
- Edit1: TEdit;
- Edit2: TEdit;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- Label6: TLabel;
- Label7: TLabel;
- Label8: TLabel;
- Label9: TLabel;
- Label10: TLabel;
- Label11: TLabel;
- Label12: TLabel;
- Label13: TLabel;
- Edit3: TEdit;
- Edit4: TEdit;
- Edit5: TEdit;
- Edit6: TEdit;
- Edit7: TEdit;
- Edit8: TEdit;
- Edit9: TEdit;
- Edit10: TEdit;
- Edit11: TEdit;
- Edit12: TEdit;
- Edit13: TEdit;
- Timer1: TTimer;
- Label14: TLabel;
- Edit14: TEdit;
- [COLOR=#0000af][B]procedure[/B][/COLOR] Timer1Timer(Sender: TObject);
- [COLOR=#0000af][B]procedure[/B][/COLOR] FormCreate(Sender: TObject);
- [COLOR=#0000af][B]private[/B][/COLOR]
- [COLOR=#008000]{ Private-Deklarationen }[/COLOR]
- [COLOR=#0000af][B]public[/B][/COLOR]
- [COLOR=#008000]{ Public-Deklarationen }[/COLOR]
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#0000af][B]var[/B][/COLOR]
- Form1: TForm1;
- [COLOR=#0000af][B]implementation[/B][/COLOR]
- [COLOR=#008000]{$R *.dfm}[/COLOR]
- [COLOR=#008000]//FUNKTIONEN[/COLOR]
- [COLOR=#008000]//------------------------------------------------------------------------------[/COLOR]
- [COLOR=#008000]//PROZESSORNAME[/COLOR]
- [COLOR=#0000af][B]function[/B][/COLOR] GetProzessorName: [COLOR=#0000af][B]string[/B][/COLOR];
- [COLOR=#0000af][B]var[/B][/COLOR] reg: TRegistry;
- [COLOR=#0000af][B]begin[/B][/COLOR]
- result:[COLOR=#0000af]=[/COLOR]'[COLOR=#000080]Unbekannter Prozessor[/COLOR]';
- reg:=TRegistry.Create;
- [COLOR=#0000af][B]try[/B][/COLOR]
- reg.RootKey :[COLOR=#0000af]=[/COLOR] HKEY_LOCAL_MACHINE;
- reg.OpenKey('[COLOR=#000080]Hardware\Description\System\CentralProcessor\0[/COLOR]', false);
- result:=reg.ReadString('[COLOR=#000080]ProcessorNameString[/COLOR]');
- [COLOR=#0000af][B]finally[/B][/COLOR]
- reg.free;
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#008000]//DERZEITIGE PROZESSORAUSLASTUNG[/COLOR]
- [COLOR=#0000af][B]function[/B][/COLOR] CalcCPUSpeed: Extended;
- [COLOR=#0000af][B]const[/B][/COLOR]
- DelayTime [COLOR=#0000af]=[/COLOR] 500; [COLOR=#008000]// measure time in ms[/COLOR]
- [COLOR=#0000af][B]var[/B][/COLOR]
- TimerHi, TimerLo: DWord;
- PriorityClass, Priority: Integer;
- [COLOR=#0000af][B]begin[/B][/COLOR]
- [COLOR=#0000af][B]try[/B][/COLOR]
- PriorityClass :[COLOR=#0000af]=[/COLOR] GetPriorityClass(GetCurrentProcess);
- Priority :[COLOR=#0000af]=[/COLOR] GetThreadPriority(GetCurrentThread);
- SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
- SetThreadPriority(GetCurrentThread,
- THREAD_PRIORITY_TIME_CRITICAL);
- [COLOR=#0000af][B]try[/B][/COLOR]
- Sleep(10);
- [COLOR=#0000af][B]asm[/B][/COLOR]
- dw 310Fh [COLOR=#008000]// rdtsc[/COLOR]
- mov TimerLo, eax
- mov TimerHi, edx
- [COLOR=#0000af][B]end[/B][/COLOR];
- Sleep(DelayTime);
- [COLOR=#0000af][B]asm[/B][/COLOR]
- dw 310Fh [COLOR=#008000]// rdtsc[/COLOR]
- sub eax, TimerLo
- sbb edx, TimerHi
- mov TimerLo, eax
- mov TimerHi, edx
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#0000af][B]finally[/B][/COLOR]
- SetThreadPriority(GetCurrentThread, Priority);
- SetPriorityClass(GetCurrentProcess, PriorityClass);
- [COLOR=#0000af][B]end[/B][/COLOR];
- Result :[COLOR=#0000af]=[/COLOR] TimerLo / (1000.0 * DelayTime);
- [COLOR=#0000af][B]except[/B][/COLOR]
- Result :[COLOR=#0000af]=[/COLOR] 0;
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#008000]//LAUFWERKE ERMITTELN[/COLOR]
- [COLOR=#0000af][B]procedure[/B][/COLOR] GetDrives([COLOR=#0000af][B]const[/B][/COLOR] AItems: TStrings);
- [COLOR=#0000af][B]const[/B][/COLOR]
- DriveTypeTexts: [COLOR=#0000af][B]array[/B][/COLOR][DRIVE_UNKNOWN..DRIVE_RAMDISK] [COLOR=#0000af][B]of[/B][/COLOR] [COLOR=#0000af][B]string[/B][/COLOR] [COLOR=#0000af]=[/COLOR]
- ('[COLOR=#000080]Unbekannt[/COLOR]', '[COLOR=#000080]Kein Wurzelverzeichnis[/COLOR]', '[COLOR=#000080]Diskette[/COLOR]', '[COLOR=#000080]Festplatte[/COLOR]', '[COLOR=#000080]Netzlaufwerk[/COLOR]', '[COLOR=#000080]CDROM[/COLOR]', '[COLOR=#000080]RAMDisk[/COLOR]');
- [COLOR=#0000af][B]var[/B][/COLOR]
- Drive: Char;
- DriveType: Integer;
- DriveMask: Integer;
- Flag: Integer;
- [COLOR=#0000af][B]begin[/B][/COLOR]
- DriveMask:=GetLogicalDrives;
- flag:=1;
- [COLOR=#0000af][B]for[/B][/COLOR] Drive :[COLOR=#0000af]=[/COLOR] '[COLOR=#000080]A[/COLOR]' [COLOR=#0000af][B]to[/B][/COLOR] '[COLOR=#000080]Z[/COLOR]' [COLOR=#0000af][B]do[/B][/COLOR]
- [COLOR=#0000af][B]begin[/B][/COLOR]
- [COLOR=#0000af][B]if[/B][/COLOR] (flag [COLOR=#0000af][B]and[/B][/COLOR] DriveMask)<>0 [COLOR=#0000af][B]then[/B][/COLOR]
- [COLOR=#0000af][B]begin[/B][/COLOR]
- DriveType :[COLOR=#0000af]=[/COLOR] GetDriveType(PChar(Format('[COLOR=#000080]%S:\[/COLOR]',[Drive]) ) ) ;
- AItems.Add(Format('[COLOR=#000080]%s: %s[/COLOR]', [Drive, DriveTypeTexts[DriveType]]));
- [COLOR=#0000af][B]end[/B][/COLOR];
- flag:=flag [COLOR=#0000af][B]shl[/B][/COLOR] 1;
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#008000]//ANZAHL DER PROZESSOREN ERMITTELN[/COLOR]
- [COLOR=#0000af][B]function[/B][/COLOR] GetNumberOfProcessors: Integer;
- [COLOR=#0000af][B]var[/B][/COLOR]
- SystemInfo: TSystemInfo;
- [COLOR=#0000af][B]begin[/B][/COLOR]
- GetSystemInfo(SystemInfo);
- Result:=SystemInfo.dwNumberOfProcessors;
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#008000]//WINDOWS UPTIME[/COLOR]
- [COLOR=#0000af][B]procedure[/B][/COLOR] GetWindowsUpTime([COLOR=#0000af][B]var[/B][/COLOR] ADay, AHours, AMinutes, ASeconds: Integer);
- [COLOR=#0000af][B]const[/B][/COLOR]
- OneDay : Integer [COLOR=#0000af]=[/COLOR] 1000 * 60 * 60 * 24;
- OneHour : Integer [COLOR=#0000af]=[/COLOR] 1000 * 60 * 60;
- OneMinutes : Integer [COLOR=#0000af]=[/COLOR] 1000 * 60;
- OneSecond : Integer [COLOR=#0000af]=[/COLOR] 1000;
- [COLOR=#0000af][B]var[/B][/COLOR]
- Start : Integer;
- d, h, m, s: Integer;
- [COLOR=#0000af][B]begin[/B][/COLOR]
- Start:=GetTickCount;
- ADay:=Start [COLOR=#0000af][B]div[/B][/COLOR] OneDay; [COLOR=#008000]//Tage[/COLOR]
- d:=Start [COLOR=#0000af][B]mod[/B][/COLOR] OneDay;
- AHours:=d [COLOR=#0000af][B]div[/B][/COLOR] OneHour; [COLOR=#008000]//Stunden[/COLOR]
- h:=d [COLOR=#0000af][B]mod[/B][/COLOR] OneHour;
- AMinutes:=h [COLOR=#0000af][B]div[/B][/COLOR] OneMinutes; [COLOR=#008000]//Minuten[/COLOR]
- s:=h [COLOR=#0000af][B]mod[/B][/COLOR] OneMinutes;
- ASeconds:=s [COLOR=#0000af][B]div[/B][/COLOR] OneSecond; [COLOR=#008000]//Sekunden[/COLOR]
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#008000]//PROGRAMMSTART[/COLOR]
- [COLOR=#008000]//------------------------------------------------------------------------------[/COLOR]
- [COLOR=#0000af][B]procedure[/B][/COLOR] TForm1.FormCreate(Sender: TObject);
- [COLOR=#0000af][B]var[/B][/COLOR]
- Memory: TMemoryStatus;
- freeCaller, total: Int64;
- [COLOR=#0000af][B]begin[/B][/COLOR]
- GetDrives(listbox1.Items);
- edit1.text:=GetProzessorName;
- edit2.Text :[COLOR=#0000af]=[/COLOR] inttostr(GetNumberOfProcessors);
- Memory.dwLength :[COLOR=#0000af]=[/COLOR] SizeOf(Memory);
- GlobalMemoryStatus(Memory);
- edit6.text:=IntToStr(Memory.dwTotalPhys [COLOR=#0000af][B]div[/B][/COLOR] 1024 [COLOR=#0000af][B]div[/B][/COLOR] 1024) +'[COLOR=#000080] MB[/COLOR]';
- GetDiskFreeSpaceEx('[COLOR=#000080]c:[/COLOR]', freeCaller, total, [COLOR=#0000af][B]nil[/B][/COLOR]);
- edit9.text:=floatToStr(total [COLOR=#0000af][B]div[/B][/COLOR] 1024 [COLOR=#0000af][B]div[/B][/COLOR] 1024 / 1024) +'[COLOR=#000080] GB[/COLOR]';
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#0000af][B]procedure[/B][/COLOR] TForm1.Timer1Timer(Sender: TObject);
- [COLOR=#0000af][B]var[/B][/COLOR]
- Tage, Stunden, Minuten, Sekunden: Integer;
- Memory: TMemoryStatus;
- SystemPowerStatus: TSystemPowerStatus;
- freeCaller, total: Int64;
- [COLOR=#0000af][B]begin[/B][/COLOR]
- edit4.Text:=IntToStr(Round(CalcCPUSpeed))+ '[COLOR=#000080] MHz[/COLOR]';
- GetWindowsUpTime(Tage, Stunden, Minuten, Sekunden);
- edit11.text :=Format('[COLOR=#000080]%d Tage %d Stunden %d Minuten %d Sekunden[/COLOR]', [Tage, Stunden, Minuten, Sekunden]);
- Memory.dwLength :[COLOR=#0000af]=[/COLOR] SizeOf(Memory);
- GlobalMemoryStatus(Memory);
- gauge1.MaxValue :[COLOR=#0000af]=[/COLOR] Memory.dwTotalPhys;
- gauge1.Progress :[COLOR=#0000af]=[/COLOR] Memory.dwAvailPhys;
- gauge2.MaxValue :[COLOR=#0000af]=[/COLOR] Memory.dwTotalPhys;
- gauge2.Progress :[COLOR=#0000af]=[/COLOR] Memory.dwTotalPhys - Memory.dwavailPhys;
- [COLOR=#008000]//Freier Arbeitsspeicher[/COLOR]
- edit7.Text :[COLOR=#0000af]=[/COLOR] inttostr(Memory.dwAvailPhys [COLOR=#0000af][B]div[/B][/COLOR] 1024 [COLOR=#0000af][B]div[/B][/COLOR] 1024)+ '[COLOR=#000080] MB[/COLOR]';
- edit8.Text :[COLOR=#0000af]=[/COLOR] inttostr(Memory.dwTotalPhys [COLOR=#0000af][B]div[/B][/COLOR] 1024 [COLOR=#0000af][B]div[/B][/COLOR] 1024 - Memory.dwavailPhys [COLOR=#0000af][B]div[/B][/COLOR] 1024 [COLOR=#0000af][B]div[/B][/COLOR] 1024)+ '[COLOR=#000080] MB[/COLOR]';
- GetSystemPowerStatus(SystemPowerStatus);
- [COLOR=#0000af][B]with[/B][/COLOR] SystemPowerStatus [COLOR=#0000af][B]do[/B][/COLOR] [COLOR=#0000af][B]begin[/B][/COLOR]
- [COLOR=#008000]// Wird das System mit Wechselstrom oder Akku betrieben ?[/COLOR]
- [COLOR=#0000af][B]case[/B][/COLOR] ACLineStatus [COLOR=#0000af][B]of[/B][/COLOR]
- 0: edit12.text :[COLOR=#0000af]=[/COLOR] '[COLOR=#000080]System wird mit Akku betrieben[/COLOR]';
- 1: edit12.text :[COLOR=#0000af]=[/COLOR] '[COLOR=#000080]System wird mit Wechselstrom betrieben[/COLOR]';
- [COLOR=#0000af][B]else[/B][/COLOR] Label5.Caption :[COLOR=#0000af]=[/COLOR] '[COLOR=#000080]Unbekannter Status[/COLOR]';
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#008000]// Ladezustand der Batterie[/COLOR]
- [COLOR=#0000af][B]case[/B][/COLOR] BatteryFlag [COLOR=#0000af][B]of[/B][/COLOR]
- 1 : edit13.text :[COLOR=#0000af]=[/COLOR] '[COLOR=#000080]Hoher Ladezustand[/COLOR]';
- 2 : edit13.text :[COLOR=#0000af]=[/COLOR] '[COLOR=#000080]Niedriger Ladezustand[/COLOR]';
- 4 : edit13.text :[COLOR=#0000af]=[/COLOR] '[COLOR=#000080]Kritischer Ladezustand[/COLOR]';
- 8 : edit13.text :[COLOR=#0000af]=[/COLOR] '[COLOR=#000080]Die Batterie wird geladen[/COLOR]';
- 128: edit13.text :[COLOR=#0000af]=[/COLOR] '[COLOR=#000080]Es existiert keine System-Batterie[/COLOR]';
- 255: edit13.text :[COLOR=#0000af]=[/COLOR] '[COLOR=#000080]Unbekannter Status[/COLOR]';
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#008000]// Ladezustand in Prozent[/COLOR]
- [COLOR=#0000af][B]if[/B][/COLOR] BatteryLifePercent <> 255 [COLOR=#0000af][B]then[/B][/COLOR]
- edit14.text :[COLOR=#0000af]=[/COLOR] IntToStr(BatteryLifePercent) + '[COLOR=#000080] %[/COLOR]'
- [COLOR=#0000af][B]else[/B][/COLOR]
- edit14.text :[COLOR=#0000af]=[/COLOR] '[COLOR=#000080]Unbekannter Status[/COLOR]';
- [COLOR=#0000af][B]end[/B][/COLOR];
- Memory.dwLength :[COLOR=#0000af]=[/COLOR] SizeOf(Memory);
- GlobalMemoryStatus(Memory);
- GetDiskFreeSpaceEx('[COLOR=#000080]c:[/COLOR]', freeCaller, total, [COLOR=#0000af][B]nil[/B][/COLOR]);
- edit10.text:=floattostr(freeCaller [COLOR=#0000af][B]div[/B][/COLOR] 1024 [COLOR=#0000af][B]div[/B][/COLOR] 1024 / 1024)+'[COLOR=#000080] GB[/COLOR]';
- [COLOR=#0000af][B]end[/B][/COLOR];
- [COLOR=#0000af][B]end[/B][/COLOR].