VC 获取当前运行窗口名称

转载请注明来源:https://www.cnblogs.com/hookjc/

BOOL CALLBACK WindowChild(HWND hwnd,LPARAM lparam)
{
 CFGDlg* dlg=(CFGDlg* )lparam;
 HWND m_hwnd=NULL;
 while(::GetParent(hwnd)!=NULL)
   m_hwnd=::GetParent(hwnd);
 char buff[255]={0};
 GetWindowText(m_hwnd,buff,sizeof(buff));
 //::SendMessage(m_hwnd,WM_GETTEXT,sizeof(buff),(LPARAM)&buff);
 if(strcmp("",buff)==0) return true;

AfxMessageBox(buff);
  return true;
}

void CFGDlg::OnButton1()
{
 // TODO: Add your control notification handler code here
 EnumWindows(WindowChild,(LPARAM)this); 
}

来源:python脚本自动迁移

猜你喜欢

转载自www.cnblogs.com/hookjc/p/13186730.html
vc