Registriert seit: 18. Mär 2004
Ort: Luxembourg
3.492 Beiträge
Delphi 7 Enterprise
|
AW: EnumDisplayDevices und DISPLAY_DEVICE
15. Jul 2013, 21:01
Dann erweiter doch die Struktur um die beiden neuene Felder, hier mal ein Beispiel:
Delphi-Quellcode:
type
_DISPLAY_DEVICEA_EX = packed record
cb: DWORD;
DeviceName: array[0..31] of AnsiChar;
DeviceString: array[0..127] of AnsiChar;
StateFlags: DWORD;
DeviceID: array[0..127] of AnsiChar;
DeviceKey: array[0..127] of AnsiChar;
end;
TDisplayDeviceAEx = _DISPLAY_DEVICEA_EX;
function EnumDisplayDevicesAEx(Unused: Pointer; iDevNum: DWORD;
var lpDisplayDevice: TDisplayDeviceAEx; dwFlags: DWORD): BOOL; stdcall;
function EnumDisplayDevicesAEx; external user32 name 'EnumDisplayDevicesA';
Und Dann benutzt Du die ganz normal:
Delphi-Quellcode:
procedure TForm1.Image1DblClick(Sender: TObject);
function B2Str(AValue : Boolean; ATrue : string = 'True'; AFalse : string = 'False') : string;
begin
if AValue then
result := ATrue
else
result := AFalse;
end;
var
Sl : TStringList;
i, c : integer;
r : TRect;
Device : _DISPLAY_DEVICEA_EX;
begin
Sl := TStringList.Create;
c := GetMonitorCount;
Sl.Add(Format('Monitore: %d', [c]));
for i := 0 to c-1 do
begin
r := GetMonitorBoundsRect(i);
Sl.Add(Format('Monitor %d (%d, %d, %d, %d) %s', [i, r.Left, r.Top, r.Right, r.Bottom, GetMonitorDevice(i)]));
end;
ZeroMemory(@Device, SizeOf(Device));
Device.cb := SizeOf(Device);
i := 0;
while EnumDisplayDevicesAEx(nil, i, Device, 0) do
begin
Sl.Add(Format('Device #%d: %s (%s) %x %s %s %s %s',
[i,
StrPas(Device.DeviceName),
StrPas(Device.DeviceString),
Device.StateFlags,
B2Str(Boolean(DISPLAY_DEVICE_ATTACHED_TO_DESKTOP and Device.StateFlags), 'Desktop', 'nix'),
B2Str(Boolean(DISPLAY_DEVICE_PRIMARY_DEVICE and Device.StateFlags), 'Primär', 'nix'),
StrPas(Device.DeviceID),
StrPas(Device.DeviceKey)
]));
inc(i);
end;
ShowMessage(Sl.Text);
Sl.Free;
end;
Ibi fas ubi proxima merces
sudo /Developer/Library/uninstall-devtools --mode=all
|
|
Zitat
|