Autor Beitrag
uranop
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149

Win XP, Win 7, Slackware 11, FreeBSD
D6E, php
BeitragVerfasst: So 21.09.08 10:00 
Hallo Jungs,

ich bin grade dabei nen "bug" zu suchen.
Bzw ich weiss garnicht ob das ueberhaupt einer ist.

Hier eine kurze Erklaerung :

Ueber das Edit25 Feld gebe ich den Hostnamen der RemoteMaschine ein ...

Die Funktion WMI auslesen sieht so aus :

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:
33:
34:
35:
36:
37:
// RAM grösse
function GetMemoryTotalPhys (wmiHost, wmiClass, wmiProperty : string):string;
var  // These are all needed for the WMI querying process
  Locator:  ISWbemLocator;
  Services: ISWbemServices;
  SObject:  ISWbemObject;
  ObjSet:   ISWbemObjectSet;
  SProp:    ISWbemProperty;
  Enum:     IEnumVariant;
  Value:    Cardinal;
  TempObj:  OleVariant;
  SN: string;
begin
  try
  Locator := CoSWbemLocator.Create;  // Create the Location object
  // Connect to the WMI service, with the root\cimv2 namespace
   Services :=  Locator.ConnectServer(wmiHost, 'root\cimv2''''''',''0nil);
  ObjSet := Services.ExecQuery('SELECT * from '+wmiClass, 'WQL',
    wbemFlagReturnImmediately and wbemFlagForwardOnly , nil);
  Enum :=  (ObjSet._NewEnum) as IEnumVariant;
  while (Enum.Next(1, TempObj, Value) = S_OK) do
  begin
    SObject := IUnknown(tempObj) as ISWBemObject;
    SProp := SObject.Properties_.Item(wmiProperty, 0);
    if VarIsNull(SProp.Get_Value) then
      result := ''
    else
    begin
      SN := SProp.Get_Value;
      result :=  SN;
    end;
  end;
  except // Trap any exceptions (Not having WMI installed will cause one!)
   on exception do
    result := '';
   end;
end;


Nachdem ich gesehen habe das nicht immer "korrekte" Werte zurueck geliefert werden,
habe ich eine Anpassung gemacht.

Die schaut dann so aus :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
 s := floattostrf ((strtoint(GetMemoryTotalPhys(Edit25.Text,'Win32_ComputerSystem','TotalPhysicalMemory')) / 1024 / 1024),fffixed,4,0);
   if strtoint(s) < 126 then Edit3.Text := '128';
   if (strtoint(s) > 130 ) AND (strtoint(s)  < 260 ) then Edit3.Text := '256';
   if (strtoint(s) > 256 ) AND (strtoint(s)  < 390 ) then Edit3.Text := '384';
   if (strtoint(s) > 390 ) AND  (strtoint(s) < 515 ) then Edit3.Text := '512';
   if (strtoint(s) > 512 ) AND  (strtoint(s) < 650 ) then Edit3.Text := '640';
   if (strtoint(s) > 640 ) AND  (strtoint(s) < 770 ) then Edit3.Text := '768';
   if (strtoint(s) > 768 ) AND  (strtoint(s) < 1030 ) then Edit3.Text := '1024';
   if (strtoint(s) > 1024 ) AND (strtoint(s)  < 1300 ) then Edit3.Text := '1280';
   if (strtoint(s) > 1280 ) AND (strtoint(s)  < 1540 ) then Edit3.Text := '1536';
   if (strtoint(s) > 1536 ) AND (strtoint(s)  < 2050 ) then Edit3.Text := '2048';
   if (strtoint(s) > 2048 ) AND (strtoint(s)  < 2570 ) then Edit3.Text := '2560';
   if (strtoint(s) > 2560 ) AND (strtoint(s)  < 3080 ) then Edit3.Text := '3072';


Ziel ist es, wie man erkennen kann, die exakten - hardware - Werte zu erhalten.

Es funktioniert soweit auch alles Tadellos ...
habe ich bei meinem Rechner erfolgreich getestet.

Bis auf 3 GiG RAM ...
Da steigt das Program aus mit der Fehlermeldung

" '3221225472' is not a valid integervalue "


Eeehm steh ich auf dem Schlauch ? Mach ich was falsch ?
Wenns bei allem anderen geht , warum dann da nicht ?

Hat da einer ne Vorstellung ?

Danke
ssb-blume
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 375
Erhaltene Danke: 7

XP, W7, W8
Deutschland
BeitragVerfasst: So 21.09.08 10:07 
Max int32 = 2147483648!!!
nimm mal int64

hi

_________________
Brain: an apparatus with which we think we think.
uranop Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149

Win XP, Win 7, Slackware 11, FreeBSD
D6E, php
BeitragVerfasst: So 21.09.08 10:17 
jihaa

vor lauter Baeumen den Wald nicht gesehen ...

Danke das war der Fehler