通过窗口句柄用递归轮询的方法拿到某个控件的句柄
HWND handle = GetForegroundWindow();
GetFilePath(handle,_T("ImageCombo"));
void GetFilePath(HWND hParentWindow,LPCTSTR lpClassName)
{
HWND hRet = NULL;
HWND hFind = NULL;
wchar_t path[256] = {0};
while ((hFind = ::FindWindowEx(hParentWindow,hFind,NULL,NULL)) != NULL){
if (!IsWindowVisible(hFind)){
continue;
}
TCHAR szClassName[1024] = {0};
if (GetClassName(hFind,szClassName,1024) > 0){
if (_tcsicmp(szClassName,lpClassName) == 0){
if(hFind != NULL)
{
/**/
return;
}
continue;
}
}
GetFilePath(hFind,lpClassName,dwSessionId);
}
}