Autor Beitrag
acnut
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 172
Erhaltene Danke: 3

Windows 7, Windows Vista, Windows XP, Ubuntu, Kubuntu, Pardus
Delphi 2010 SV, Java Editor, VS 2010 SV
BeitragVerfasst: Di 25.05.10 22:04 
ich habe zwei codes von swissdelphicenter.ch, aber leider weiß ich nicht wie ich das verbinden soll.

www.swissdelphicente...showcode.php?id=1010
und
www.swissdelphicente.../showcode.php?id=593

ich hab das so gemacht aber komm auf keine lösung es wird immer 0% angezeigt(in der refresh prozedur):
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
var
  i: Integer;
  bContinue: BOOL;
  NewItem,a: TListItem;

begin
  ListView1.Items.Clear;
  aSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  aProcessEntry32.dwSize := SizeOf(aProcessEntry32);
  bContinue := Process32First(aSnapshotHandle, aProcessEntry32);
  while Integer(bContinue) <> 0 do
  begin
    NewItem := ListView1.Items.Add;
    NewItem.Caption := ExtractFileName(aProcessEntry32.szExeFile);
    NewItem.subItems.Add(IntToHex(aProcessEntry32.th32ProcessID, 4));
    a := ListView1.Items.Add;

    NewItem.subItems.Add(aProcessEntry32.szExeFile);
    bContinue := Process32Next(aSnapshotHandle, aProcessEntry32);
Process.PID := th32ProcessID}; 

// Zeitwerte müssen auf null gesetzt werden 
Process.lNewKernel := 0
Process.lNewUser   := 0
Process.dwNewTime  := 0

// speichert die aktuellen Zeitwerte im Datensatz 
RefreshProcess(Process); 

a.Caption :=GetCPUTimeForProcess(Process);
  end;
  CloseHandle(aSnapshotHandle);



mfg
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: Di 25.05.10 22:21 
Und wie sieht der Code von RefreshProcess und GetCPUTimeForProcess aus? Oder sind das eingebaute Funktionen?
Und hast du schonmal Haltepunkte gesetzt und geguckt, ob du z.B. überhaupt ein gültiges Handle bekommst?

_________________
PROGRAMMER: A device for converting coffee into software.
acnut Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 172
Erhaltene Danke: 3

Windows 7, Windows Vista, Windows XP, Ubuntu, Kubuntu, Pardus
Delphi 2010 SV, Java Editor, VS 2010 SV
BeitragVerfasst: Mi 26.05.10 06:47 
user profile iconXentar hat folgendes geschrieben Zum zitierten Posting springen:
Und wie sieht der Code von RefreshProcess und GetCPUTimeForProcess aus? Oder sind das eingebaute Funktionen?
Und hast du schonmal Haltepunkte gesetzt und geguckt, ob du z.B. überhaupt ein gültiges Handle bekommst?


das ganze ist schin eingebaut.
es wird kein fehler angezeigt, aber % ist falsch.
wahrscheinlich gehört das in eine eigene schleife,oder?:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
  a := ListView1.Items.Add;


Process.PID := th32ProcessID}; 

// Zeitwerte müssen auf null gesetzt werden 
Process.lNewKernel := 0
Process.lNewUser   := 0
Process.dwNewTime  := 0

// speichert die aktuellen Zeitwerte im Datensatz 
RefreshProcess(Process); 

a.Caption :=GetCPUTimeForProcess(Process);



mfg
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 26.05.10 09:18 
Mit "eingebaut" meinte ich, ob das eine selbstgeschrieben Funktion von dir ist.
Da mein Delphi diese Funktion nicht kennt, geh ich mal davon aus, dass es was selbst geschriebenes ist, ja. Also: Wie sieht davon der Code aus?

Und was möchtest du an der Stelle mit ner Schleife..?

_________________
PROGRAMMER: A device for converting coffee into software.
acnut Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 172
Erhaltene Danke: 3

Windows 7, Windows Vista, Windows XP, Ubuntu, Kubuntu, Pardus
Delphi 2010 SV, Java Editor, VS 2010 SV
BeitragVerfasst: Mi 26.05.10 17:36 
nein eigentlich nicht.
hab die codes von swissdelphicenter und versuche diese beiden codes zu verbinden.
weiß allerdings nicht wie ich das anstellen soll



mfg