<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Anthony here is a windows info version.I didnt saw your code so I wrote a very test version with some options, check it and if you want different or more tell me.It will compile with last fpc and Lazarus version or your nightly build.<br></div>
<div> </div>
<blockquote><div><div>unit Unit1;</div>
<div> </div>
<div>{$mode delphi}</div>
<div> </div>
<div>interface</div>
<div> </div>
<div>uses</div>
<div> Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,</div>
<div> ActiveX, ComObj, Variants, LCLIntf;</div>
<div> </div>
<div>{ TForm1 }</div>
<div> </div>
<div>type</div>
<div> TForm1 = class(TForm)</div>
<div> ListBox1: TListBox;</div>
<div> ListBox2: TListBox;</div>
<div> procedure FormActivate(Sender: TObject);</div>
<div> procedure FormCreate(Sender: TObject);</div>
<div> private</div>
<div> public</div>
<div> procedure GetCPUInfo;</div>
<div> procedure GetCPUUsage;</div>
<div> const</div>
<div> WbemUser = '';</div>
<div> WbemPassword = '';</div>
<div> WbemComputer = 'localhost';</div>
<div> wbemFlagForwardOnly = $00000020;</div>
<div> var</div>
<div> FSWbemLocator: olevariant;</div>
<div> FWMIService: olevariant;</div>
<div> end;</div>
<div> </div>
<div>var</div>
<div> Form1: TForm1;</div>
<div> </div>
<div>implementation</div>
<div> </div>
<div>{$R *.lfm}</div>
<div> </div>
<div>{ TForm1 }</div>
<div> </div>
<div>procedure TForm1.FormCreate(Sender: TObject);</div>
<div>begin</div>
<div> FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');</div>
<div> FWMIService := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, WbemPassword);</div>
<div>end;</div>
<div> </div>
<div>procedure TForm1.FormActivate(Sender: TObject);</div>
<div>begin</div>
<div> GetCPUInfo;</div>
<div> while True do</div>
<div> begin</div>
<div> GetCPUUsage;</div>
<div> Application.ProcessMessages;</div>
<div> end;</div>
<div>end;</div>
<div> </div>
<div>procedure TForm1.GetCPUInfo;</div>
<div>var</div>
<div> FWbemObjectSet: olevariant;</div>
<div> FWbemObject: olevariant;</div>
<div> oEnum: IEnumvariant;</div>
<div> pCeltFetched: cardinal;</div>
<div>begin</div>
<div> FWbemObjectSet := FWMIService.ExecQuery('SELECT * FROM Win32_Processor', 'WQL', wbemFlagForwardOnly);</div>
<div> </div>
<div> oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;</div>
<div> </div>
<div> while oEnum.Next(1, FWbemObject, pCeltFetched) = 0 do</div>
<div> begin</div>
<div> with ListBox1.Items do</div>
<div> begin</div>
<div> Add(FWbemObject.Name);</div>
<div> Add(FWbemObject.Caption);</div>
<div> Add(FWbemObject.Description);</div>
<div> Add(FWbemObject.Manufacturer);</div>
<div> Add(FWbemObject.ProcessorId);</div>
<div> Add(IntToStr(FWbemObject.NumberOfCores));</div>
<div> Add(IntToStr(FWbemObject.NumberOfLogicalProcessors));</div>
<div> Add(FWbemObject.Status);</div>
<div> end;</div>
<div> </div>
<div> FWbemObject := Unassigned;</div>
<div> end;</div>
<div> </div>
<div> FWbemObjectSet := FWMIService.ExecQuery('SELECT * FROM Win32_Processor', 'WQL', wbemFlagForwardOnly);</div>
<div> </div>
<div> oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;</div>
<div> </div>
<div> while oEnum.Next(1, FWbemObject, pCeltFetched) = 0 do</div>
<div> begin</div>
<div> ListBox1.Items.Add(IntToStr(FWbemObject.CurrentClockSpeed));</div>
<div> ListBox1.Items.Add(IntToStr(FWbemObject.MaxClockSpeed));</div>
<div> FWbemObject := Unassigned;</div>
<div> end;</div>
<div>end;</div>
<div> </div>
<div>procedure TForm1.GetCPUUsage;</div>
<div>var</div>
<div> FWbemObjectSet: olevariant;</div>
<div> FWbemObject: olevariant;</div>
<div> oEnum: IEnumvariant;</div>
<div> pCeltFetched: cardinal;</div>
<div> Tick: int64;</div>
<div>begin</div>
<div> Tick := GetTickCount;</div>
<div> FWbemObjectSet := FWMIService.ExecQuery('SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor', 'WQL', wbemFlagForwardOnly);</div>
<div> </div>
<div> oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;</div>
<div> </div>
<div> ListBox2.Items.Clear;</div>
<div> while oEnum.Next(1, FWbemObject, pCeltFetched) = 0 do</div>
<div> begin</div>
<div> ListBox2.Items.Add(FWbemObject.Name + ' ' + IntToStr(FWbemObject.PercentProcessorTime));</div>
<div> </div>
<div> FWbemObject := Unassigned;</div>
<div> end;</div>
<div> self.Caption := IntToStr(GetTickCount - Tick);</div>
<div>end;</div>
<div> </div>
<div>end.</div>
</div>
</blockquote><div> </div>
<div>PS. because list wont let me attach the project I will send you directly a sample one.<br></div>
<div> </div>
<div id="defanged23-sig12586409"><div class="defanged23-signature">Regards,<br></div>
<div class="defanged23-signature">Ara<br></div>
</div>
<div> </div>
<div> </div>
<div id="sig12586409"><div class="signature">Regards,<br></div>
<div class="signature">Ara<br></div>
</div>
<div> </div>
<div> </div>
<pre>
--
http://www.fastmail.com - Or how I learned to stop worrying and
love email again
</pre>
</body>
</html>