Lazarus

Programming => Operating Systems => Windows => Topic started by: TheProgrammer on August 18, 2011, 01:24:53 am

Title: Windows Hardware information/Windows hardver információ (Multilang)
Post by: TheProgrammer on August 18, 2011, 01:24:53 am
Hungarian:
Hogyan tudom elérni a processzor magok számát, gyorsítótár nagyságát MB-ban és órajel sebességét a processzorhoz?
Szükségem van ezekre: Intel vagy AMD, 64bit vagy 32-bit, processzor sorozatszáma, szálak száma...

English:
How can I access the number of processor cores, cache size in MB and the CPU clock speed?
I need these: Intel or AMD, 64-bit or 32-bit, processor serial number, number of threads...

Other
{$asmmode Intel}
or
{$mode Delphi}

- AMD is working on? /AMD is támogatja?/

Code: [Select]
Sleep(10);
asm
  dw 310Fh
  mov TimerLo, eax
  mov TimerHi, edx
end;

Sleep(DelayTime);
asm
  dw 310Fh
  sub eax, TimerLo
  sbb edx, TimerHi
  mov TimerLo, eax
  mov TimerHi, edx
end; 
Title: Re: Windows Hardware information/Windows hardver információ
Post by: avra on August 18, 2011, 10:34:58 am
For Windows you should query WMI.

General WMI info:
http://en.wikipedia.org/wiki/Windows_Management_Instrumentation

Lazarus related WMI info:
http://www.lazarus.freepascal.org/index.php/topic,11569.msg74342.html#msg74342
Title: Re: Windows Hardware information/Windows hardver információ
Post by: TheProgrammer on August 19, 2011, 03:00:32 am
I use Win7, Lazarus 0.9.30, FPC 2.4.2...

Does not display the CPU information, but very different ...
Nem jelzi ki a CPU információt de mást igen...

Basic code is not?
Windows Registry is the same as everywhere in the data?
Available Win7 and XP as well?
Alap kód nincs?
Windows Registry-ben lévő adatok mindenhol egyeznek?
Elérhető Win7 és XP  alatt egyaránt?
Title: Re: Windows Hardware information/Windows hardver információ
Post by: TheProgrammer on August 19, 2011, 07:38:18 pm
Hu: Köszönöm! Megtaláltam a megoldást! Ez az 'Activex' nagyon jó!
En: Thank you! I found the solution! This is the 'ActiveX' very good!

Code: [Select]
/--------------------------------------------------------------------------------------------------
//     This code was generated by the Wmi Delphi Code Creator http://theroadtodelphi.wordpress.com
//     Version: 1.1.2.153
//
//
//
//     LIABILITY DISCLAIMER
//     THIS GENERATED CODE IS DISTRIBUTED "AS IS". NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED.
//     YOU USE IT AT YOUR OWN RISK. THE AUTHOR NOT WILL BE LIABLE FOR DATA LOSS,
//     DAMAGES AND LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS CODE.
//
//
//------------------------------------------------------------------------------------------------
program GetWMI_Info;

{$mode objfpc} {$H+}

uses
  SysUtils,
  ActiveX,
  ComObj,
  Variants;
               


// The Win32_Processor class represents a device that is capable of interpreting a
// sequence of machine instructions on a Win32 computer system. On a
// multiprocessor machine, there will exist one instance of this class for each
// processor.

procedure  GetWin32_ProcessorInfo;
const
  WbemUser            ='';
  WbemPassword        ='';
  WbemComputer        ='localhost';
  wbemFlagForwardOnly = $00000020;
var
  FSWbemLocator : OLEVariant;
  FWMIService   : OLEVariant;
  FWbemObjectSet: OLEVariant;
  FWbemObject   : Variant;
  oEnum         : IEnumvariant;
  sValue        : string;   
begin;
  FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
  FWMIService   := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, WbemPassword);
  FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM Win32_Processor','WQL',wbemFlagForwardOnly);
  oEnum         := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
  while oEnum.Next(1, FWbemObject, nil) = 0 do
  begin
    sValue:= FWbemObject.Properties_.Item('L2CacheSize').Value;
    Writeln(Format('L2CacheSize    %s',[sValue]));// Uint32
   
    Writeln('');
    FWbemObject:=Unassigned;
  end;
end;


begin
 try
    GetWin32_ProcessorInfo;
 except
    on E:EOleException do
        Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode]));     
on E:Exception do
        Writeln(E.Classname, ':', E.Message);
 end;
 Writeln('Press Enter to exit');
 Readln;   
end.
Title: Re: Windows Hardware information/Windows hardver információ
Post by: TheProgrammer on August 21, 2011, 06:47:51 pm
Ez a lekérdezés 2-3 másodpercet vesz igénybe.
Programszálba raktam, de semmi értelme.
2-3 másodpercre befagy a program így is.
Több lekérdezés esetén a program hoszabb időre használhatatlan.
Mit tegyek?

This query takes 2-3 seconds.
I put in Thread, but it makes no sense.
2-3 seconds, the program still freezes.
Several queries Longer term, the program is useless.
What can I do?

Példa/Example:
1GetWin32_ProcessorInfo; -> 2 Second
And^2GetWin32_BiosInfo; -> 2+2 Second
And^xGet... -> 2+2x second

More info/További információ:
http://lazarus.freepascal.org/index.php/topic,14346.msg75911/topicseen.html#new
TinyPortal © 2005-2018