(Gast)
n/a Beiträge
|
AW: Routine gesucht, die feststellt, ob Monitor an oder aus.
28. Apr 2013, 11:25
GetDevicePowerState von '\\.\LCD'
Delphi-Quellcode:
function GetDevicePowerState(hDevice:DWORD;var pfOn:BOOL):BOOL; stdcall; external kernel32;
function CheckMonitorState:Boolean;
var
Hwnd:THandle;
Stat:LongBool;
begin
Hwnd:=CreateFile('\\.\LCD' , 0, 0, nil, OPEN_EXISTING, 0, 0);
if Hwnd <> INVALID_HANDLE_VALUE then GetDevicePowerState(Hwnd,Stat);
Result:=Stat;
CloseHandle(Hwnd);
end;
//Beispiele
procedure TForm1.FormCreate(Sender: TObject);
begin
if CheckMonitorState then Caption:='Monitor ON' else Caption:='Monitor OFF';
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if CheckMonitorState then Panel1.Color:= clGreen else Panel1.Color:= clRed;
end;
|
|
Zitat
|