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脚本自动迁移

posted @ 2020-06-24 11:35  jiangcheng_15  阅读(454)  评论(0编辑  收藏  举报