Advertisement

09.03.2008 at 11:25AM PDT, ID: 23700281
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

How get information about Processor in Delphi

Asked by Lagu_ in Delphi Programming Language

Tags: , ,

How get information about Processor:
- number of processors (not cores)
- temperature
- name (like "Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz")
- description (like "Description: x86 Family 6 Model 15 Stepping 11")
- clock speed
- processor id

If I try do that with code below I get: name, description, clock speed, processorid correctly.
But number of processor with Core2 Quad (4 cores): 4
In case Athlon 64 X2(2 cores): 1Start Free Trial
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:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, WbemScripting_TLB, activex, IpHlpApi;
 
type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
  aString  = array of string;
  a2String = array [0..1] of aString;
 
type
  pDevices = ^tDevices;
  tDevices = record
    Next : pDevices;
    Vals : a2String;
  end;
 
  procedure CreateList;
  procedure AddToList(Tablica : a2String);
  procedure DestroyList;
  procedure PrintAll(Memo : TMemo);
  function  getPropValue(sprop:ISWbemProperty):string;
  procedure getAdapters(owner:TComponent; wmiClass : string; Model : aString);
 
var
  Form1              : TForm1;
  Root, Last         : pDevices;
  LAN_root, LAN_last : pLAN_Devices;
 
implementation
 
{$R *.dfm}
 
uses
  IpTypes;
 
  procedure CreateList;
  begin
    Root := nil;
    Last := nil;
  end;
 
  procedure AddToList(Tablica : a2String);
    var
      NewOne      : pDevices;
      tmp_tablica : a2String;
      i, n        : integer;
  begin
    New(NewOne);
    NewOne^.Next := nil;
    n := Length(Tablica[0]);
    SetLength(tmp_tablica[0], n);
    SetLength(tmp_tablica[1], n);
    for i := 0 to n - 1 do begin
      tmp_tablica[0][i] := Tablica[0][i];
      tmp_tablica[1][i] := Tablica[1][i];
    end;
    NewOne^.Vals := tmp_tablica;
    if Root = nil then begin
      Root := NewOne;
      Last := Root;
    end else begin
      Last^.Next := NewOne;
      Last := NewOne;
    end;
  end;
 
  procedure DestroyList;
    var
      ToDelete  : pDevices;
  begin
    while Root <> nil do begin
      ToDelete := Root;
      Root     := Root^.Next;
      Dispose(ToDelete);
    end;
  end;
 
  procedure PrintAll(Memo : TMemo);
    var
      Lista    : pDevices;
      Lista_   : a2String;
      i, n     : integer;
  begin
    Lista := Root;
    while Lista <> nil do begin
      Lista_ := Lista^.Vals;
      n := Length(Lista_[0]);
      for i := 0 to n - 1 do Memo.Lines.Add(' ------ ' + Lista_[0][i] + ': ' + Lista_[1][i]);
      Lista := Lista^.Next;
      Memo.Lines.Add('');
    end;
    DestroyList;
  end;
 
  function getPropValue(sprop:ISWbemProperty):string;
    var
      sValue : string;
      count  : integer;
  begin
    sValue := '';
    if VarIsNull(SProp.Get_Value) then sValue := 'null'
    else
      case SProp.CIMType of
        wbemCimtypeSint8, wbemCimtypeUint8, wbemCimtypeSint16, wbemCimtypeUint16,
        wbemCimtypeSint32, wbemCimtypeUint32, wbemCimtypeSint64:
          sValue := IntToStr(SProp.Get_Value);
        wbemCimtypeString, wbemCimtypeUint64:
          if VarIsArray(SProp.Get_Value) then begin
            if VarArrayHighBound(SProp.Get_Value, 1) > 0 then
              for Count := 1 to VarArrayHighBound(SProp.Get_Value, 1) do
                sValue := sValue + ' ' + SProp.Get_Value[Count];
          end else sValue :=  SProp.Get_Value;
        wbemCimtypeDatetime:
          sValue:=SProp.Get_Value;
        else
          Exception.Create('Unknown type');
      end; {case}
    result:=sValue;
  end;
 
  procedure getAdapters(owner:TComponent; wmiClass : string; Model : aString);
    var
      Locator            : TSWbemLocator;
      SinkClasses        : TSWbemSink;
      Services           : ISWbemServices;
      ObjectSet          : ISWbemObjectSet;
      SObject            : ISWbemObject;
      propSet            : ISWbemPropertySet;
      SProp              : ISWbemProperty;
      Enum               : IEnumVariant;
      tempObj            : OleVariant;
      Value              : Cardinal;
      sValue             : String;
      i, j, w1           : integer;
      data               : a2String;
      test               : boolean;
  begin
    w1 := Length(Model);
    SetLength(data[0], w1);
    SetLength(data[1], w1);
    Locator     := TSWbemLocator.Create(owner);
    SinkClasses := TSWbemSink.Create(owner);
    try
      SinkClasses.Cancel;
      Services  := Locator.ConnectServer('.', 'root\CIMV2', '', '', '', '', 0, nil);
      ObjectSet := Services.InstancesOf(wmiClass, wbemFlagReturnImmediately or wbemQueryFlagShallow, nil);
      Enum      := (ObjectSet._NewEnum) as IEnumVariant;
      SetLength(Model, w1);
      CreateList;
      while (Enum.Next(1, tempObj, Value) = S_OK) do begin
        SObject := IUnknown(tempObj) as SWBemObject;
        propSet := SObject.Properties_;
        test    := false;
        for j := 0 to w1 - 1 do begin
          data[0][j] := Model[j];
          data[1][j] := '';
          SProp   := propSet.Item(Model[j], 0);// caption or systemname
          sValue  := getPropValue(SProp);
          if sValue<>'null' then begin
            data[1][j] := sValue;
            test := true;
          end;
        end;
        if test then AddToList(data);
      end; {while Enum}
    finally
    end; {try}
    Locator.Free;
    SinkClasses.Free;
    Services:=nil;
    ObjectSet:=nil;
    SObject:=nil;
    enum:=nil;
  end;
 
  procedure TForm1.Button1Click(Sender: TObject);
    var
      Model    : aString;
  begin
    Memo1.Clear;
 
    Memo1.Lines.Add(''); Memo1.Lines.Add('Procesor');
    SetLength(Model, 4);
    Model[0] := 'Name'; Model[1] := 'Description'; Model[2] := 'CurrentClockSpeed'; Model[3] := 'ProcessorId';
    getAdapters(self, 'Win32_Processor', Model);
    PrintAll(Memo1);
    SetLength(Model, 1);
    Model[0] := 'NumberOfProcessors';
    getAdapters(self, 'Win32_ComputerSystem', Model);
    PrintAll(Memo1);
    Memo1.SetFocus;
  end;
 
end.
[+][-]09.03.2008 at 12:57PM PDT, ID: 22381276

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Delphi Programming Language
Tags: Microsoft, Windows, Processor
Sign Up Now!
Solution Provided By: ziolko
Participating Experts: 1
Solution Grade: B
 
 
[+][-]09.04.2008 at 03:01AM PDT, ID: 22385576

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 03:35AM PDT, ID: 22385764

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 03:37AM PDT, ID: 22385769

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 04:32AM PDT, ID: 22386025

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 04:36AM PDT, ID: 22386056

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 04:46AM PDT, ID: 22386129

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 04:55AM PDT, ID: 22386202

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 04:57AM PDT, ID: 22386208

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 05:02AM PDT, ID: 22386246

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 06:46AM PDT, ID: 22387183

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080924-EE-VQP-38 / EE_QW_2_20070628