求救!
  菜鸟求救大虾!用VC如何实现在打开的所有窗口里,关闭含有指定字符窜标题的窗口呢?分不够在加!解决马上给分!

解决方案 »

  1.   

    遍历所有窗口,发现符合要求的窗口,发送关闭消息我的bolg里面有遍历窗口的例子
    http://blog.csdn.net/bobob
      

  2.   

    我的代码:
    #include  <windows.h>
    #include  <iostream>using namespace std;BOOL CALLBACK MyEnumFunc(HWND  hWnd, LPARAM  lParam)
    {
    char  temp[128] = {0};
    GetWindowText(hWnd, temp, 128);
    if (temp[0] == 0)
    return true; //输出窗口名
    cout << temp << endl;
    char  str[128];
    strcpy(str, (const char*)lParam);
    if (strstr(temp, str) != 0)
    {
    cout << "找到窗口。。!" << endl;
    //这里是关闭指定窗口, 可以改成别的动作
    ::PostMessage(hWnd, WM_CLOSE, 0, 0);
    }
    return true;
    }void main()
    {
    char szCaptionSubstr[128] = "EnumWindow"; //查找所有窗口名字中有EnumWindow子串的窗口
    ::EnumWindows(MyEnumFunc, (long)szCaptionSubstr);
    }