COM works in VB but not VC.
-
Here is a VB test app. It is not very complex or clever, but it works. Dim WithEvents mcs As MCSClient mcs.Initialize "MyString" where MCSClient is a com object added to the VB environment by adding a reference. Not a component, but a reference. I would like an equivalent VC app to this VB app. So I wrote some code like this. I use the Wizard to generate a wrapper class over the same dll the VB referenced and in my header I define a variable of the wrapper type as such. IMCSClient m_IMCSClient; Then in my code I successfully create the dispatch like so. if(((*(COleDispatchDriver*)(&m_IMCSClient))).m_lpDispatch==NULL){ if (!(m_IMCSClient.CreateDispatch("4E51E425-021E-11D2-B759-0020AFF84106", &oe))) { } } I can also use the progid in creating the dispatch, either way works. Here comes the problem, I want to perform the Initialze method. (Just like VB did.) m_IMCSClient.Initialize("MyString); When, this code excutes it will throw the following exception. DISP_E_MEMBERNOTFOUND I am not sure what it means. Is anyone familar enough with VB to know what WithEvents means? Can anyone suggest a different course of action.
-
Here is a VB test app. It is not very complex or clever, but it works. Dim WithEvents mcs As MCSClient mcs.Initialize "MyString" where MCSClient is a com object added to the VB environment by adding a reference. Not a component, but a reference. I would like an equivalent VC app to this VB app. So I wrote some code like this. I use the Wizard to generate a wrapper class over the same dll the VB referenced and in my header I define a variable of the wrapper type as such. IMCSClient m_IMCSClient; Then in my code I successfully create the dispatch like so. if(((*(COleDispatchDriver*)(&m_IMCSClient))).m_lpDispatch==NULL){ if (!(m_IMCSClient.CreateDispatch("4E51E425-021E-11D2-B759-0020AFF84106", &oe))) { } } I can also use the progid in creating the dispatch, either way works. Here comes the problem, I want to perform the Initialze method. (Just like VB did.) m_IMCSClient.Initialize("MyString); When, this code excutes it will throw the following exception. DISP_E_MEMBERNOTFOUND I am not sure what it means. Is anyone familar enough with VB to know what WithEvents means? Can anyone suggest a different course of action.
Hi ! When you create the object in VB using "WithEvens" it means that the object can fire events. See VB documentation for more details. You are trying to use the IDispatch interface but probably the object you are using supports dual interfaces. It's much easier from C++ and much faster. You can use the #import directive with the name of the DLL file you are using to import the type library information and the use the QueryInterface function. Regards, Alex Gorev, Dundas Software. ================== The original message was: Here is a VB test app. It is not very complex or clever, but it works.
Dim WithEvents mcs As MCSClient
mcs.Initialize "MyString"where MCSClient is a com object added to the VB environment by adding a reference. Not a component, but a reference.
I would like an equivalent VC app to this VB app. So I wrote some code like this.
I use the Wizard to generate a wrapper class over the same dll the VB referenced and in my header I define a variable of the wrapper type as such.
IMCSClient m_IMCSClient;
Then in my code I successfully create the dispatch like so.
if(((*(COleDispatchDriver*)(&m_IMCSClient))).m_lpDispatch==NULL){
if (!(m_IMCSClient.CreateDispatch("4E51E425-021E-11D2-B759-0020AFF84106", &oe))) {
}
}I can also use the progid in creating the dispatch, either way works.
Here comes the problem, I want to perform the Initialze method. (Just like VB did.)
m_IMCSClient.Initialize("MyString);When, this code excutes it will throw the following exception.
DISP_E_MEMBERNOTFOUNDI am not sure what it means.
Is anyone familar enough with VB to know what WithEvents means?
Can anyone suggest a different course of action.