1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,Forms,
Dialogs, StdCtrls, SetupAPI;
const
GUID_CLASS_MONITOR: TGUID = '{4D36E96E-E325-11CE-BFC1-08002BE10318}';
type
TForm1 = class(TForm)
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetMonitorInfo: boolean;
var
hdi: HDEVINFO;
begin
hdi := SetupDiGetClassDevs(@GUID_CLASS_MONITOR, nil, 0, DIGCF_PRESENT);
if cardinal(hdi) = INVALID_HANDLE_VALUE then
begin
Result := False;
{ HANDLE non trouvée et fin des opérations }
end
else
begin
{ HANDLE valide, et possibilité d'utiliser encore d'autres fonctions
de l'Api Device Management tel que SetupDiEnumDeviceInfo,
SetupDiGetDeviceRegistryProperty, etc pour récupérer les informations
sur le moniteur }
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
GetMonitorInfo;
end;
end. |
Partager