Click here to Skip to main content
15,913,487 members
Home / Discussions / COM
   

COM

 
AnswerRe: Global OLE instance pointers - Termination hangs Pin
CPallini9-Jun-09 6:18
mveCPallini9-Jun-09 6:18 
AnswerRe: Global OLE instance pointers - Termination hangs Pin
Stuart Dootson9-Jun-09 22:27
professionalStuart Dootson9-Jun-09 22:27 
QuestionHOW CAN I ADD dll to windows .net application Pin
lnmca5-Jun-09 22:17
lnmca5-Jun-09 22:17 
AnswerRe: HOW CAN I ADD dll to windows .net application Pin
Stuart Dootson6-Jun-09 4:30
professionalStuart Dootson6-Jun-09 4:30 
GeneralRe: HOW CAN I ADD dll to windows .net application Pin
Md. Marufuzzaman6-Jul-09 22:02
professionalMd. Marufuzzaman6-Jul-09 22:02 
GeneralRe: HOW CAN I ADD dll to windows .net application Pin
Stuart Dootson6-Jul-09 22:04
professionalStuart Dootson6-Jul-09 22:04 
AnswerRe: HOW CAN I ADD dll to windows .net application Pin
Sonhospa12-Jun-09 1:29
Sonhospa12-Jun-09 1:29 
QuestionRedirecting JavaScript Function Calls to My C++ Code Pin
kochikoo5-Jun-09 2:29
kochikoo5-Jun-09 2:29 
Hi,

I want to redirect JavaScript functions (such as alert, open etc) calls to be redirected to my code written in C++. I launch IE from my application that implements an event sink to listen to various events by IE.

- I have inherited a class from IDispatch and implemented only Invoke that handles DISPID_VALUE.
- The next thing i did is call Invoke using my class dispatch pointer with DISPID_VALUE.
- After that i get dispid to the function (say alert()) in global scripting object whose call i want to redirect to my class.
- Using this dispid as the parameter, i call Invoke with global scripting object retrieved from get_Script().
- Doing so gives me error DISP_E_BADVARTYPE (bad variable type).

Following is the code:

//==============================
CComObject<cmycomobj> *pObj = NULL;

DISPPARAMS dispparams, dispparamsNoArgs = {NULL, NULL, 0, 0};
VARIANT var;
dispparams.rgvarg=NULL;
dispparams.rgdispidNamedArgs=NULL;
dispparams.cArgs=0;
dispparams.cNamedArgs=0;

//Create my class object.
pObj->CreateInstance(&pObj);
pObj->QueryInterface(IID_IUnknown, (void **) &punkTemp);
hr = punkTemp->QueryInterface(IID_IDispatch, (void **) &pDispMyObj);

//Call invoke to get the required info from parameters passed.
hr = pDispMyObj->Invoke(DISPID_VALUE, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
&dispparams, &var, NULL, NULL);

//Get global scripting object DispatchEx pointer
m_spInetExplorer-&get_Document(&pDisp);
pDisp->QueryInterface(IID_IHTMLDocument2, (void **) &pHTMLDocument2);
pHTMLDocument2->get_Script(&pDispSE);
pDispSE->QueryInterface(IID_IDispatchEx, (void **) &DispExSE);

//Set arguments that will be sent with the invoke call below.
DISPID putid = DISPID_PROPERTYPUT;
dispparams.rgvarg = &var;
dispparams.rgdispidNamedArgs = &putid;
dispparams.cArgs = 1;
dispparams.cNamedArgs = 1;

BSTR strOpen = SysAllocString(OLESTR("alert"));
DISPID dispIDAlert;

//Get dispid of the function that is to be hooked in this case alert().
hr = pDispExSE->GetDispID(strOpen, fdexNameEnsure, &dispIDAlert);

//Here it returns the error DISP_E_BADVARTYPE.
//Call invoke with DISPATCH_PROPERTYPUT to install hooks.
hr = pDispExSE->InvokeEx(dispIDAlert, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &dispparams,
NULL, NULL, NULL);
//==============================

Please let me know if such a thing is possible. If so then is this the right way to achieve this? What am i doing wrong here?

Thanks for your help.
AnswerRe: Redirecting JavaScript Function Calls to My C++ Code Pin
kochikoo15-Jun-09 21:44
kochikoo15-Jun-09 21:44 
GeneralRe: Redirecting JavaScript Function Calls to My C++ Code Pin
nat32_support21-Jun-09 13:43
nat32_support21-Jun-09 13:43 
QuestionQuerying WMI from inside WMI Provider Pin
krishiyengar4-Jun-09 9:23
krishiyengar4-Jun-09 9:23 
AnswerRe: Querying WMI from inside WMI Provider Pin
Baltoro4-Jun-09 14:02
Baltoro4-Jun-09 14:02 
GeneralRe: Querying WMI from inside WMI Provider Pin
krishiyengar5-Jun-09 5:46
krishiyengar5-Jun-09 5:46 
GeneralRe: Querying WMI from inside WMI Provider Pin
Baltoro6-Jun-09 8:35
Baltoro6-Jun-09 8:35 
GeneralRe: Querying WMI from inside WMI Provider Pin
krishiyengar8-Jun-09 3:04
krishiyengar8-Jun-09 3:04 
GeneralRe: Querying WMI from inside WMI Provider Pin
krishiyengar8-Jun-09 6:02
krishiyengar8-Jun-09 6:02 
QuestionPROBLEM IN MDAC version2.6 Pin
RAJAGOPALMS762-Jun-09 0:08
RAJAGOPALMS762-Jun-09 0:08 
QuestionHow to get Defalut interface of CoClass Pin
vibindia1-Jun-09 23:55
vibindia1-Jun-09 23:55 
AnswerRe: How to get Defalut interface of CoClass Pin
«_Superman_»2-Jun-09 0:21
professional«_Superman_»2-Jun-09 0:21 
AnswerRe: How to get Defalut interface of CoClass Pin
vibindia2-Jun-09 0:37
vibindia2-Jun-09 0:37 
AnswerRe: How to get Defalut interface of CoClass [modified] Pin
Lim Bio Liong6-Jun-09 5:32
Lim Bio Liong6-Jun-09 5:32 
QuestionHow to customise the window xp print dialog. Pin
manjari kar30-May-09 1:23
manjari kar30-May-09 1:23 
QuestionDebugging WMI Providers Pin
krishiyengar28-May-09 7:26
krishiyengar28-May-09 7:26 
AnswerRe: Debugging WMI Providers Pin
Stuart Dootson28-May-09 8:08
professionalStuart Dootson28-May-09 8:08 
GeneralRe: Debugging WMI Providers Pin
krishiyengar29-May-09 2:10
krishiyengar29-May-09 2:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.