Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
RAD-Studio 2010 Arc
|
AW: Name der Grafikkarte auslesen, wie?
20. Okt 2015, 22: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 EnumDisplayDevices 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;
]
|
|
Zitat
|