1.根据程序名称获取程序窗口句柄
//一个程序获取另一个程序Edit控件的内容
char temp[256];
strTest.clear();
//根据指定程序的标题名获取改程序窗口的句柄
HWND hWnd = ::FindWindow(NULL, L"Test");
if (hWnd!=NULL)
{
EnumChildWindows(hWnd, EnumWindowsProc, NULL);
UpdateData(0);
}
vector<CString> strTest;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
if (hwnd != 0)
{
char temp[256];
CString str;
int nValue = ::SendMessage(hwnd, WM_GETTEXT, 255, (LPARAM)temp);
if (nValue != 0)
{
str.Format(_T("%s"), temp);
}
strTest.push_back(str);
return TRUE;
}
return FALSE;
}
3.strTest内部是窗体显示的所有值。