您可以使用窗口事件来监听EVENT_OBJECT_SHOW事件:
SetWinEventHook( EVENT_OBJECT_SHOW, EVENT_OBJECT_SHOW, NULL, MyWinEventProc,
0, 0, WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
然后,在您的事件过程中,您可以检查显示的窗口是否是 Dragon 助手:
void CALLBACK MyWinEventProc(
HWINEVENTHOOK hWinEventHook,
DWORD event,
HWND hwnd,
LONG idObject,
LONG idChild,
DWORD dwEventThread,
DWORD dwmsEventTime
)
{
if (idObject == OBJID_WINDOW) // the window itself is being shown
{
// compare window class and/or title here
WCHAR szClass[255];
if (GetClassName(hwnd, szClass, ARRAYSIZE(szClass)) != 0 &&
wcscmp(szClass, "WhatEverDragonAssistantClassNameIs") == 0)
{
// the Dragon Assistant is showing; notify the rest of your app here
}
}
}