Einzelnen Beitrag anzeigen

hathor
(Gast)

n/a Beiträge
 
#17

AW: Name der Grafikkarte auslesen, wie?

  Alt 21. Okt 2015, 00:48
Mit WMI-Win32_VideoController:

Delphi-Quellcode:
uses ...Winapi.ActiveX, System.Win.comobj,...

const
MyArray : Array[1..21]of String =(
'Other',
'Unknown',
'Running/Full Power',
'Warning',
'In Test',
'Not Applicable',
'Power Off',
'Off Line',
'Off Duty',
'Degraded',
'Not Installed',
'Install Error',
'Power Save - Unknown',
'Power Save - Low Power Mode',
'Power Save - Standby',
'Power Cycle',
'Power Save - Warning',
'Paused',
'Not Ready',
'Not Configured',
'Quiesced - temporarily inactive');

Procedure GRAFIK;
const wbemFlagForwardOnly = $00000020;
var
  FSWbemLocator : OLEVariant;
  FWMIService : OLEVariant;
  FWbemObjectSet: OLEVariant;
  FWbemObject : OLEVariant;
  oEnum : IEnumvariant;
  iValue : LongWord;
  i : Integer;
begin;
//Form1.Memo1.clear;
i:=0;
  FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
  FWMIService := FSWbemLocator.ConnectServer('localhost', 'root\cimv2', '', '');
  FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM Win32_VideoController','WQL',wbemFlagForwardOnly);
  oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
  while oEnum.Next(1, FWbemObject, iValue) = 0 do
  begin
      if not VarIsNull(FWbemObject.DeviceID) then
      Form1.Memo1.lines.add(Format('Device ID %s',[String(FWbemObject.DeviceID)]));
// if not VarIsNull(FWbemObject.PNPDeviceID) then
// Form1.Memo1.lines.add(Format('PNP Device ID %s',[String(FWbemObject.PNPDeviceID)]));
    if not VarIsNull(FWbemObject.Description) then
      Form1.Memo1.lines.add(Format('Description %s',[String(FWbemObject.Description)]));

// if not VarIsNull(FWbemObject.Caption) then
// Form1.Memo1.lines.add(Format('Caption %s',[String(FWbemObject.Caption)]));
    if not VarIsNull(FWbemObject.Availability) then BEGIN
// Form1.Memo1.lines.add(Format('Availibility %s',[String(FWbemObject.Availability)]));
      Form1.Memo1.lines.add(MyArray[Integer(FWbemObject.Availability)]); END;
// if not VarIsNull(FWbemObject.VideoProcessor) then
// Form1.Memo1.lines.add(Format('VideoProcessor %s',[String(FWbemObject.VideoProcessor)]));
    inc(i);
    if I=1 then
    BEGIN
    Form1.Label1.caption:= MyArray[Integer(FWbemObject.Availability)];
    Form1.Memo1.lines.add('----------------------------------------------');
    END;
    if I=2 then Form1.Label2.caption:= MyArray[Integer(FWbemObject.Availability)];
    FWbemObject:=Unassigned;
  end;
end;

procedure TForm1.ButtonClick(Sender: TObject);
begin
GRAFIK;
end;
Ergebnis Beispiel:
Device ID VideoController1
Description Intel(R) HD Graphics 4000
Running/Full Power
----------------------------------------------
Device ID VideoController2
Description NVIDIA GeForce GT 635M
Off Line
  Mit Zitat antworten Zitat