AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Name der Grafikkarte auslesen, wie?
Thema durchsuchen
Ansicht
Themen-Optionen

Name der Grafikkarte auslesen, wie?

Ein Thema von Delphi-Noobie · begonnen am 26. Jan 2004 · letzter Beitrag vom 20. Okt 2015
Antwort Antwort
Roy Altenau

Registriert seit: 7. Okt 2015
3 Beiträge
 
#1

AW: Name der Grafikkarte auslesen, wie?

  Alt 11. Okt 2015, 15:34
Warum zeigt es unter win7/8/10 davor soviel müll an, kann man das vermeiden?
  Mit Zitat antworten Zitat
Benutzerbild von Remko
Remko

Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
 
RAD-Studio 2010 Arc
 
#2

AW: Name der Grafikkarte auslesen, wie?

  Alt 20. Okt 2015, 21:23
I think querying registry is not the best approach, especially as some systems have multiple gpu's (eg NVidia Optimus).
You can get this information by calling MSDN-Library durchsuchenEnumDisplayDevices in a loop, eg:

Delphi-Quellcode:
function TForm1.DumpFlags(const Flags: DWORD): String;
begin
  Result := '';
  if Flags and DISPLAY_DEVICE_ACTIVE = DISPLAY_DEVICE_ACTIVE then
    Result := Result + 'DISPLAY_DEVICE_ACTIVE | ';
  if Flags and DISPLAY_DEVICE_MIRRORING_DRIVER = DISPLAY_DEVICE_MIRRORING_DRIVER then
    Result := Result + 'DISPLAY_DEVICE_MIRRORING_DRIVER | ';
  if Flags and DISPLAY_DEVICE_MODESPRUNED = DISPLAY_DEVICE_MODESPRUNED then
    Result := Result + 'DISPLAY_DEVICE_MODESPRUNED | ';
  if Flags and DISPLAY_DEVICE_PRIMARY_DEVICE = DISPLAY_DEVICE_PRIMARY_DEVICE then
    Result := Result + 'DISPLAY_DEVICE_PRIMARY_DEVICE | ';
  if Flags and DISPLAY_DEVICE_REMOVABLE = DISPLAY_DEVICE_REMOVABLE then
    Result := Result + 'DISPLAY_DEVICE_REMOVABLE | ';
  if Flags and DISPLAY_DEVICE_VGA_COMPATIBLE = DISPLAY_DEVICE_VGA_COMPATIBLE then
    Result := Result + 'DISPLAY_DEVICE_VGA_COMPATIBLE | ';

  if Result.Length > 0 then
    Result := Copy(Result, 1, Result.Length - 3);
end;

procedure TForm1.btnEnumClick(Sender: TObject);
var
  i, j: Integer;
  DisplayDevice: DISPLAY_DEVICE;
  MonitorDevice: DISPLAY_DEVICE;
  bRes: Boolean;
  DeviceName: String;
begin
  i := 0;

  for i := 0 to 255 do
  begin
    ZeroMemory(@DisplayDevice, SizeOf(DisplayDevice));
    DisplayDevice.cb := SizeOf(DisplayDevice);
    bRes := EnumDisplayDevices(nil, i, DisplayDevice, 0);
    if not bRes then
      Break;

    Memo1.Lines.Add(Format('iDevNum : %d', [i]));
    Memo1.Lines.Add(Format('DeviceName : %s', [DisplayDevice.DeviceName]));
    Memo1.Lines.Add(Format('DeviceString: %s', [DisplayDevice.DeviceString]));
    Memo1.Lines.Add(Format('Flags : %s', [DumpFlags(DisplayDevice.StateFlags)]));

    for j := 0 to 255 do
    begin

      DeviceName := DisplayDevice.DeviceString;
      ZeroMemory(@MonitorDevice, SizeOf(MonitorDevice));
      MonitorDevice.cb := SizeOf(MonitorDevice);

      bRes := EnumDisplayDevices(DisplayDevice.DeviceName, j, MonitorDevice, 0);
      if not bRes then
        Break;

      Memo1.Lines.Add(Format(' iDevNum : %d', [j]));
      Memo1.Lines.Add(Format(' DeviceName : %s', [MonitorDevice.DeviceName]));
      Memo1.Lines.Add(Format(' DeviceString: %s', [MonitorDevice.DeviceString]));
      Memo1.Lines.Add(Format(' Flags : %s', [DumpFlags(MonitorDevice.StateFlags)]));
    end;
  end;
end;
]
See my blog blog
See our Jedi blog
  Mit Zitat antworten Zitat
hathor
(Gast)

n/a Beiträge
 
#3

AW: Name der Grafikkarte auslesen, wie?

  Alt 20. Okt 2015, 23: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
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:30 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz