COM DCOM uses ID binding to find a method or property of a COM object. We have discussed topics like C++ static binding, C++ dynamic binding, DCOM ID binding, GetIDsOfNames etc. Please visit this page C++ static binding, C++ dynamic binding, DCOM ID binding, GetIDsofName() function in IDispatch()?
Invoke function can be used to get or set object properties and calling object methods. GetIDsOfNames is used to get the dispatch identity number of the property or method and same number is passed to Invoke to call the actual procedure.
HRESULT Invoke( [in] DISPID dispIdMember, [in] REFIID riid, [in] LCID lcid, [in] WORD wFlags, [in, out] DISPPARAMS *pDispParams, [out] VARIANT *pVarResult, [out] EXCEPINFO *pExcepInfo, [out] UINT *puArgErr );
- dispIdMember [in] Unique number which identifies the member property or method returned by GetIDsOfNames.
- riid [in] Reserved and must be IID_NULL.
- lcid [in] The locale context in which to interpret arguments.
- wFlags [in] Flags describing the context of the Invoke call.
- DISPATCH_METHOD The member is invoked as a method. If a property has the same name, both this and the DISPATCH_PROPERTYGET flag can be set.
- DISPATCH_PROPERTYGET The member is retrieved as a property or data member.
- DISPATCH_PROPERTYPUT The member is changed as a property or data member.
- DISPATCH_PROPERTYPUTREF The member is changed by a reference assignment, rather than a value assignment. This flag is valid only when the property accepts a reference to an object.
- pDispParams [in, out] Pointer to a DISPPARAMS structure containing an array of arguments, an array of argument DISPIDs for named arguments, and counts for the number of elements in the arrays.
- pVarResult [out] Pointer to the location where the result is to be stored, or NULL if the caller expects no result. This argument is ignored if DISPATCH_PROPERTYPUT or DISPATCH_PROPERTYPUTREF is specified.
- pExcepInfo [out] Pointer to a structure that contains exception information. This structure should be filled in if DISP_E_EXCEPTION is returned. Can be NULL.
- puArgErr [out] The index within rgvarg of the first argument that has an error. Arguments are stored in pDispParams->rgvarg in reverse order, so the first argument is the one with the highest index in the array. This parameter is returned only when the resulting return value is DISP_E_TYPEMISMATCH or DISP_E_PARAMNOTFOUND. This argument can be set to null. For details, see Returning Errors.
This method can return S_OK on Success and various error codes - DISP_E_BADPARAMCOUNT, DISP_E_BADVARTYPE, DISP_E_EXCEPTION,DISP_E_MEMBERNOTFOUND, DISP_E_NONAMEDARGS, DISP_E_OVERFLOW, DISP_E_PARAMNOTFOUND, DISP_E_TYPEMISMATCH, DISP_E_UNKNOWNINTERFACE, DISP_E_UNKNOWNLCID, DISP_E_PARAMNOTOPTIONAL etc.
We are using Invoke method to set the Visible property of IWebBrowser to TRUE and then calling Invoke to call Navigate method and browsing google.com. Disp IDs are taken from our previous example using GetIDsOfNames(). This will make Internet explorer visible and then it will open google.com.
About our authors: Team EQA
You have viewed 1 page out of 67. Your COM/DCOM learning is 0.00% complete. Login to check your learning progress.
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Draw on printer Memory leaks Best Hosting plans, 80% discounts