I have a task, that includes grabbing some text that lie inside a third party ActiveX component that's embedded inside Internet Explorer webpage using "OBJECT id=S_DetectCom codeBase=xxxx.cab ..."
i have the .cab file having the activeX dlls(4 dlls)
i'm not familiar with OLE and activeX, but doing some research and trials , i could get an IDispatch to ActiveX object by the following steps :-
1- get handle to IE tab having class "Internet Explorer_Server"
2- get IHTMLDocument2 using ObjectFromLresult
3- get IHTMLElementCollection from IHTMLDocument2
4- get IDispatch from IHTMLElementCollection with element of name "S_DetectCom"
what lies in mind, is getting the typelib from DLLs to know the methods,... and their parameters by try and error find which dll in the cab is embedded into that web page
right now i'm stuck, as i don't know how to reach Invoke to call methods from IDispatch i got
i'd appreciate if somebody could help me with ideas and implementation below is the code part that gets IDispatch from hwnd
int msg;
DWORD lRes = NULL ;
IHTMLDocument2 *pDoc= NULL;
IHTMLElementCollection *pElement = NULL ;
IHTMLInputTextElement *ppvInput ;
IDispatch *ppvDisp;
ITypeInfo *TypeInfo = NULL ;
VARIANT ObjName ;
_variant_t index = NULL;
HRESULT hr;
LRESULT lr ;
UINT cntTypeInf= NULL ;
long pItems = NULL;
BSTR pszOptText[200];
OleInitialize(NULL);
msg = RegisterWindowMessage(L"WM_HTML_GETOBJECT");
lr = SendMessageTimeout(hwnd, msg, 0, 0, SMTO_ABORTIFHUNG, 1000, &lRes);
hr = ObjectFromLresult((LRESULT)lRes, IID_IHTMLDocument2, 0, (void**)&pDoc);
hr = pDoc->get_all( &pElement );
BSTR BStrObjName = _com_util::ConvertStringToBSTR((const char *)"S_DetectCom");
ObjName.vt = VT_BSTR ;
ObjName.bstrVal = BStrObjName ;
hr = pElement->item( ObjName , index , &ppvDisp );
if (hr == S_OK && ppvDisp)
{
hr = ppvDisp->GetTypeInfoCount(&cntTypeInf);
hr = ppvDisp->GetTypeInfo(NULL , NULL , &TypeInfo);
// to do here
}