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



BeitragVerfasst: Mi 10.12.08 00:22 
Hi,

ich versuche gerade meinen Arbeitsspeicher, bzw den noch freien Arbeitsspeicher mir anziegen zu lassen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  memory: Tmemorystatus;
begin
  memory.dwLength := SizeOf(memory);
  GlobalMemoryStatus(memory);
  //Arbeitsspeicher
  edit1.text:=IntToStr(Memory.dwTotalPhys div (1024*1024));
  //Freier Arbeitsspeicher
  edit2.text:=IntToStr(Memory.dwAvailPhys div (1024*1024));
end;


Das ergebniss ist aber irgentwie unglaubwürdig:

Ich habe bei beiden eine Ausgabe von 1023...

Eig. habe ich 4gb ram und im moment verbrauche ich 35% davon, laut Windoof.

Was mach ich falsch?
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 10.12.08 10:15 
user profile iconethillias hat folgendes geschrieben Zum zitierten Posting springen:
Was mach ich falsch?

Du liest nicht die Hilfe:
Windows SDK hat folgendes geschrieben:
On computers with more than 4 GB of memory, the GlobalMemoryStatus function can return incorrect information. Windows 2000 and later report a value of -1 to indicate an overflow. Earlier versions of Windows NT report a value that is the real amount of memory, modulo 4 GB. For this reason, use the GlobalMemoryStatusEx function instead.

Und du überprüfst nicht den Rückgabewert.
ethillias Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41



BeitragVerfasst: Mi 10.12.08 11:18 
ok danke für den tipp werde das gleich testen.

Hmm also irgentwie bekomm ich das grad nicht hin kannste mir sagen was ich da ändern muss? in meiner Hilfe kann ich auch kein GlobalMemorystatusEX finden.
jfheins
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 918
Erhaltene Danke: 158

Win 10
VS 2013, VS2015
BeitragVerfasst: Mi 10.12.08 11:26 
Du musst nur in der richtigen Hilfe suchen :P

z.B. so: search.live.com/resu...usEX&form=STOHSS

Die richtige Hilfe ist das msdn/windows-sdk

Evtl. hilfreich ist der Post aus der DP (der interessanterweise noch vor dem Microsoft-treffer kommt ...)
ethillias Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41



BeitragVerfasst: Mi 10.12.08 11:37 
Habe mir bei deinem link mal den post von Lucky angeguckt, verstehe dort aber nichtwas

TMemoryStatusEx = packed record

bedeuten soll.

wenn ich das versuche einfach zu übernehmen bekomm ich nen Fehler das er eig. einen : erwartet und wenn ich das änder meckert er über das packed.

Vielleicht bin ich schwer von Begriff^^.

Hab aber jetzt erstma Unterricht, später wieder da.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 10.12.08 11:47 
Ich kann es einfach in ein neues Projekt kopieren und es läuft.
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 11:56 
Du musst das auch an die richtige Stelle kopieren..
was du da hast, ist ein TYPE.
Ich vermute mal, du hast es im Moment irgendwoe unter VAR stehen - das geht nicht.

_________________
PROGRAMMER: A device for converting coffee into software.
ethillias Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41



BeitragVerfasst: Mi 10.12.08 14:57 
Ich hab das dort drin wo ich meine das es hinkommt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ComCtrls, ColorButton, Ping, WinSock, Gauges,
  TextTrayIcon, CoolTrayIcon, Menus;

const
  SyncPing  = 0;
  AsyncPing = 1;

type
  TDesktopManager = class(TForm)
    TMemoryStatusEx = packed record;


Ergebniss: Expected ':' but '=' found.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 10.12.08 15:03 
Die Deklaration gehört nicht in eine andere hinein...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
type
  TMemoryStatusEx = packed record

  end;

  TDesktopManager = class(TForm)
  private
  public
  end;
ethillias Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41



BeitragVerfasst: Mi 10.12.08 15:11 
Ok danke wusste ich nicht, habs hinbekommen.