2011-10-30 66 views

回答

5

FindWindow()要求完整標題。在循環中使用EnumWindows()GetWindow()來枚舉所有可用的窗口,每個窗口都會調用GetClassName()GetWindowText(),並將這些值與您的搜索條件進行比較,直至找到匹配項。

2

事情是這樣的:

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) { 
    wchar_t lpClassName[128] = {0}; 
    MYSTRUCT* MS_INFO   = (MYSTRUCT*)lParam; 

    GetClassName(hwnd, lpClassName, _countof(lpClassName)); 
    if(strstr(lpClassName, MS_INFO -> lpClassName)) { 
    wchar_t lpWindowName[128] = {0}; 
    GetWindowText(hwnd, lpWindowName, _countof(lpWindowName)); 

    if(strstr(lpWindowName, MS_INFO -> lpWindowName)) { 
     ... 
    } 
    } 
}