Autor Beitrag
ethillias
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41



BeitragVerfasst: Mi 10.12.08 16:39 
hi,

ich möchte gerne die Cpu Auslastung in einer Gauge angezeigt bekommen, hierzu hatte ich mir folgendes überlegt:

ausblenden Delphi-Quelltext
1:
   CPUBAR.progress:=StrToInt(Format('%5.2f%',[GetCPUUsage(GetCPUCount-1)*100]));					


Das problem ist das dabei eine Kommazahl ausgegeben wird (z.b. 12,34) nu kann ich aus 12,34 keinen Int machen da man dazu entweder eine ganze Zahl oder einen Punkt anstat einem Komma braucht. Wie kann ich das lösen?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 10.12.08 16:43 
Wie wäre es mit runden? Round? Dann brauch man das ganze String-Rumgehampele auch nicht. ;-)

_________________
We are, we were and will not be.
ethillias Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41



BeitragVerfasst: Mi 10.12.08 16:48 
ja das mit dem Round hab ich auch schon überlegt aber ich schaff es nicht zu runden weil das anscheinend nur mit einem punkt geht.

Wenn es doch geht könntest du mir das vllt mal so aufschreiben wie es dann gehen würde?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 10.12.08 16:51 
Was hat denn der Punkt damit zu tun? :gruebel:

ausblenden Delphi-Quelltext
1:
CPUBAR.progress:= Round(GetCPUUsage(GetCPUCount-1)*100);					

_________________
We are, we were and will not be.
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mi 10.12.08 16:52 
ausblenden Delphi-Quelltext
1:
   CPUBAR.progress:=round(GetCPUUsage(GetCPUCount-1)*100);					

?

Edit: zu langsam..

_________________
PROGRAMMER: A device for converting coffee into software.


Zuletzt bearbeitet von Xentar am Mi 10.12.08 16:53, insgesamt 1-mal bearbeitet
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 10.12.08 16:53 
Was redest du da eigentlich immer von einem Punkt? In welcher Form liefert denn GetCPUUsage die CPU-Auslastung zurück? Als Zeichenkette mit Komma als Dezimaltrennzeichen? Um die Funktion Round nutzen zu können benötigt man natürlich eine (Fließ)kommazahl.
ethillias Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41



BeitragVerfasst: Mi 10.12.08 16:54 
ähm gute frage^^ , funktioniert jedenfals was du da gemacht hast. Hab mich da wohl etwas verwurschtelt.

Danke