function GetScreenSaverRunning : boolean;
var
res : integer
begin
SystemParametersInfo(GETSCREENSAVERRUNNING , 0, @res, 0);
Result := boolean(res);
end;
判斷是否正在電腦鎖定(螢幕保護及CTRL+ALT+DEL跳出另外的視窗也會判斷到)
function IsWorkstationLocked: Boolean;
var
hDesktop: HDESK;
begin
Result := False;
hDesktop := OpenDesktop('default', 0, False, DESKTOP_SWITCHDESKTOP);
if hDesktop <> 0 then
begin
Result := not SwitchDesktop(hDesktop);
CloseDesktop(hDesktop);
end;
end;
判斷是否正在關機、待命、休眠或關閉硬碟
function TEncodeVideoWindowProc(hWnd:HWND; iMsg:Integer; wParam:WPARAM; lParam:LPARAM): Integer; stdcall;
begin
Result:=0;
case iMsg of
WM_DESTROY :
begin
PostQuitMessage(0); //跟Windows說我要退出囉。
exit;
end;
WM_POWERBROADCAST: begin
case wParam of
PBT_APMQUERYSUSPEND:begin
//LogToFile('收到待命、休眠或關閉硬碟的須求');
end;
PBT_APMRESUMESUSPEND:begin
//LogTofile('收到電腦從待命、休眠或關閉硬碟返回的須求,及前錄影格數');
end;
end;
end;
WM_QUERYENDSESSION:
begin
;
end;
end;
Result := DefWindowProc(hWnd,iMsg,wParam,lParam); //不感興趣的消息,由windows去處理
end;
沒有留言:
張貼留言