15,471
社区成员
发帖
与我相关
我的任务
分享
foreach (Process p in Process.GetProcesses())
{
string a=p.MainWindowHandle;//进程主窗口的窗口句柄
string b=p.MainWindowTitle;//进程主窗口窗口名称
}
//回调函数:
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lparam)
{
TCHAR lpWinTitle[256];
::GetWindowText(hwnd,lpWinTitle,256-1);
CString m_strTitle;
m_strTitle.Format(_T("%s"),lpWinTitle);
if(m_strTitle.GetLength())
AfxMessageBox(m_strTitle);
return TRUE;
}
//调用回调函数:
::EnumWindows(EnumWindowsProc,0);
然后你自己根据你的需要过滤一下遍历到的窗口就行了
::FindWindow()