请写的完整一点,谢谢了。。

解决方案 »

  1.   

    用spy++查到任务栏的hand
    然后在程序里,PostMessage(hand,WM_CLOSE,0,0);
      

  2.   

    下面的程序能实现关闭在任务条上显示的任何应用程序
    CString strCaption;
    CWnd * pDistWnd;
    pDistWnd=AfxGetMainWnd()->GetWindow (GW_HWNDFIRST);
    while (pDistWnd)
    {
         if (pDistWnd ->IsWindowVisible()&& pDistWnd ->GetWindowTextLength ()&&! pDistWnd ->GetOwner ())
    {
         pDistWnd ->GetWindowText (strCaption);
         if(strCaption.Find("目标窗口的Caption",0)!=-1)
            break;
    }
    pDistWnd=pDistWnd->GetWindow(GW_HWNDNEXT);//Get next window 
    }
    if(pDistWnd!=NULL)
       pDistWnd->PostMessage(WM_CLOSE,NULL,NULL);