当屏幕保护程序关闭时,我试图捕捉事件。实际上,目前,我没有收到任何屏幕保护程序事件(也没有在启动时)。当应用程序处于焦点(前景)时,我正在对其进行测试。
这是我的代码:
#include "stdafx.h"
#include "windows.h"
LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
static void RegisterWindowClasses() {
WNDCLASS wndClass;
memset(&wndClass, 0, sizeof(WNDCLASS));
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.hInstance = NULL;
wndClass.lpszClassName = _T("Plugin-Video");
wndClass.hbrBackground = (HBRUSH) GetStockObject (DKGRAY_BRUSH);
wndClass.lpfnWndProc = wndProc;
RegisterClass(&wndClass);
}
LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (msg)
{
case WM_SYSCOMMAND:
{
switch (LOWORD(wParam))
{
case SC_SCREENSAVE:
{
FILE *fl = fopen("this_is_a_event_test.txt","a");
fputs("SC_SCREENSAVE\n",fl);
fclose(fl);
}
break;
case SC_MONITORPOWER:
{
FILE *fl = fopen("this_is_a_event_test.txt","a");
fputs("SC_MONITORPOWER\n",fl);
fclose(fl);
}
break;
default:
{
}
}
}
break;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
int _tmain(int argc, _TCHAR* argv[])
{
RegisterWindowClasses();
while(1){}
return 0;
}
有什么建议么?谢谢!