Thema: Delphi Grafikspeicher auslesen

Einzelnen Beitrag anzeigen

hathor
(Gast)

n/a Beiträge
 
#2

Re: Grafikspeicher auslesen

  Alt 7. Jul 2008, 12:45
Mit WMI:

'Win32_VideoController','AdapterRAM'

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,
  ActiveX, WbemScripting_TLB;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Label1: TLabel;
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  aLoc: ISWbemLocator;
  aSrv: ISWbemServices;
  aObjSet: ISWbemObjectSet;
  pEnum: IEnumVARIANT;
  vOut: OleVariant;
  dwRetrieved: LongWord;
  hRes: HResult;
  cWQL, sWQL: string;
  st: TStringList;

implementation

{$R *.dfm}

function GetWMIstring (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;
   Services := Locator.ConnectServer(wmiHost, 'root\cimv2', '', '', '','', 0, nil);
  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;


procedure TForm1.FormActivate(Sender: TObject);
var tmpstr : string;
begin
tmpstr := getWMIstring('','Win32_VideoController ','AdapterRAM');
  if tmpstr <> 'then Label1.caption:= tmpstr +' Bytes VideoRAM';
end;

end.
  Mit Zitat antworten Zitat