Autor Beitrag
brainkopf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP; Win 7
C# (VS 2005/2008)
BeitragVerfasst: Sa 24.11.07 18:13 
Hi,
Ich würde gerne die CPU Auslastung in einer ProgressBar anzeigen. Leider habe ich bisjetzt noch nirgends was passendes gefunden. Wenn mir jemand die Lösung sagen könnte, wäre ich sehr dankbar. bei Dual Cores oder Quad Cores sollte die Durschnittsauslastung pro Kern angegeben werden.
Ist sowas möglich?

mfg
brainkopf
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 24.11.07 18:52 
brainkopf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP; Win 7
C# (VS 2005/2008)
BeitragVerfasst: Sa 24.11.07 19:51 
Kann evtl. jemand das ganze hier hochladen,
weil ich kann gerade nicht auf meine emails zugreifen weil er server tot ist.
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 24.11.07 20:04 
Im Anhang ist der Source Code:
Einloggen, um Attachments anzusehen!


Zuletzt bearbeitet von hathor am Sa 24.11.07 20:30, insgesamt 1-mal bearbeitet

Für diesen Beitrag haben gedankt: talpar
brainkopf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP; Win 7
C# (VS 2005/2008)
BeitragVerfasst: Sa 24.11.07 20:13 
vielen Dank!
Ich schaus mir mal an!

Edit: das ist kein Code! Das ist ne .exe!!
brainkopf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP; Win 7
C# (VS 2005/2008)
BeitragVerfasst: Sa 24.11.07 20:41 
Muss ich da noch irgenetwas davor installieren?
Das funktioniert nicht.
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 24.11.07 20:59 
user profile iconbrainkopf hat folgendes geschrieben:
Muss ich da noch irgenetwas davor installieren?
Das funktioniert nicht.


Das findet man im Systray - nach dem Anklicken wird das Programm beendet.
Du musst es entsprechend ändern.
brainkopf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP; Win 7
C# (VS 2005/2008)
BeitragVerfasst: Do 06.12.07 17:13 
hmm. also nach Copy und Paste und abändern, funzt das immer noch nicht.
Liegt das vielleicht an meinem Delphi?
ich hab Turbo Delphi 2006
brainkopf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP; Win 7
C# (VS 2005/2008)
BeitragVerfasst: Fr 07.12.07 19:06 
also wie im oberen Post schon erwähnt ist, funktioniert da sganze bei mir nicht so wirklich.

Also dieser Part funktioniert: Das auslesen des Memory Usage:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm4.Timer1Timer(Sender: TObject);
var
  x, y : real;
  memory: TMemoryStatus;
  Auslastung: integer;
  MS: TMemoryStatus;
begin
  memory.dwLength := SizeOf(memory);
  GlobalMemoryStatus(memory);
  x := memory.dwTotalPhys - memory.dwAvailPhys;
  y := memory.dwTotalPhys;
  Auslastung := round(((x/y)*100));
  FreeResBar.Position := Auslastung;
end;


Nur irgendwie bekomme ich es nicht hin das auf die cpu auslastung zuzuschneiden!

Moderiert von user profile iconjasocul: Highlight- durch Delphi-Tags ersetzt
Blawen
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 616
Erhaltene Danke: 33

Win XP, Vista, 7
Delphi 5 Prof., BDS 2006 Prof. RAD Studio XE
BeitragVerfasst: Fr 07.12.07 19:38 
user profile iconbrainkopf hat folgendes geschrieben:
Nur irgendwie bekomme ich es nicht hin das auf die cpu auslastung zuzuschneiden!
Diese Procedur ist irgendwie ja auch auf den Speicher zugeschnitten. Abändern genügt also nicht...

Im Verzeichnis liegt auch eine Datei Namens "adCpuUsage.pas", Du musst sie eigentlich nur verwenden...!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
uses
    Windows, SysUtils,unit1,Dialogs;

// Call CollectCPUData to refresh information about CPU usage
procedure CollectCPUData;

// Call it to obtain the number of CPU's in the system
function GetCPUCount: Integer;

// Call it to obtain the % of usage for given CPU
function GetCPUUsage(Index: Integer): Double;

// For Win9x only: call it to stop CPU usage monitoring and free system resources
procedure ReleaseCPUData;

_________________
Es kompilert, wir können ausliefern.
Und es kompiliert wieder - das Update ist fertig - bitte 100 Euro ;-)
brainkopf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP; Win 7
C# (VS 2005/2008)
BeitragVerfasst: Sa 08.12.07 14:14 
so. jetzt markiert der mir aber das hier rot!

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
adCpuUsage, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Menus, FileCtrl, Buttons;


was ist da Falsch`? Also das adCpuUsage ist anscheinen falsch!
Die adCpuUsage.pas ist im Verzeichnis und zum Projekt hinzugefügt worden!
OlafSt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 486
Erhaltene Danke: 99

Win7, Win81, Win10
Tokyo, VS2017
BeitragVerfasst: Mo 10.12.07 11:52 
Danke für die aussagekräftige Fehlermeldung, die du gepostet hast.

_________________
Lies, was da steht. Denk dann drüber nach. Dann erst fragen.
brainkopf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP; Win 7
C# (VS 2005/2008)
BeitragVerfasst: Mo 10.12.07 16:42 
tut mir leid. ich hatte wenig Zeit. Hier etwas umfangreicher.

Also. Wie schon gesagt, das Programm markiert folgendes rot:


uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
adCpuUsage, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Menus, FileCtrl, Buttons;

Die Datei adCpuUsage.pas ist im Projekt mit drin und wird ja eigentlich mit der oberen Anweisung mit eingefügt!

Außerdem zeigt er noch folgenen Fehler an!

[Pascal Fataler Feher] Main.pas(7): F2047 Zirkuläre Unit-Referenz auf 'Main'

So. ich hoff eihr könnt damit was anfangen!
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 11.12.07 08:29 
adCpuUsage steht doch weiter unten schon drin - also: muss es oben raus!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
implementation

{$R *.dfm}

uses adCpuUsage;
.
.
.
brainkopf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP; Win 7
C# (VS 2005/2008)
BeitragVerfasst: Di 11.12.07 17:59 
danke!
Daran habe ich gar nicht gedacht!!!