检测桌面切换事件

DWORD WINAPI find_explorer_thread_proc(LPVOID param)
{
	HANDLE desktop_event = OpenEvent(SYNCHRONIZE, FALSE, L"WinSta0_DesktopSwitch");
	if (!desktop_event) {
		printf("OpenEvent() failed: %lu", GetLastError());
		return 1;
	}
	while (1) {
		DWORD wait_ret = WaitForSingleObject(desktop_event, INFINITE);
		switch (wait_ret) {
		case WAIT_OBJECT_0:
			SetEvent((HANDLE)param);
			break;
		case WAIT_TIMEOUT:
		default:
			printf("WaitForSingleObject(): %lu", wait_ret);
		}
	}
	CloseHandle(desktop_event);
	return 0;
}


 

你可能感兴趣的:(检测桌面切换事件)