|
-
April 16th, 2010, 07:03 AM
#1
EventHandling in COM Using IDispatch with out using idl and midl
Hi
I am stuck in my project, where we are basically using native interfaces with java using jni.
The requirement : There is a com dll provided for us and the document explaining its interfaces, let me call it as servercom.dll, which is basically using another general api, called as server api. I need to use the servercom.dll for getting the data from certain hardwares and pass it to the java for processing in a different application.
Where I AM now : The Java and C++ interfacing part is done, where i am creating my own dll file which inturn uses servercom.dll. my own dll is loaded in java using the system.loadlibrary. Basically interfacing with c++ is done. In c++ i am successfull in creating the instance of my required interface using ::cocreateinstance passing the CLSID objtained from servercom.dll .
Now the core issue is that, after creating my instances i need to do the even handling using connection points, where generally it will be taking IUnknown, but here they want IDispatch interface and they will be calling the even handler functions using idispatch :: invoke method. So i need to implement the IDispatch interface and pass it to the connection point. The twist is , for creating idispatch interface , it seems to be very complex as we cannot use midl compiler and idl files. because i am not using ms ide. but i am using the cl.exe compiler and link.exe linker for compiling and linking and creating the myown.dll. So i want your help in creating IDispatch interface in such a scenario.
they have implemented another classes for events specific for the interface like below
IAdaptorEvents : IDispatch{
virtual doWhatEvents(BSTR str) = 0;
virtual doWhatEverEvent(BSTR str) = 0;
}
so basically i need to create a class inheriting from this one like myAdaptorEventsListener : IAdaptorEvents - this point we need to implement 4 methods of IDispatch + 3 methods of IUnknown + the event Handler Methods(which is 2 in this case).
When implementing 4 Methods from IDispatch - GetTypeInfoCount and Get TypeInfo and Invoke and GetIDsof Names, i am totally lost here
as i need to creat ITypeInfo interface and lot of other things also. There was an example in MSDN http://msdn.microsoft.com/en-us/library/ms221237.aspx - where i am not getting NEARDATA, i dont know where they are declaring this. So in total Some one please let me know how to create an IDispatch interface by impolementing all those functions properly. and there are some stuffs like method id and all which i am not able to understand completely, May be because i am not a good c++ programmer. But my dear kind hearted friends please help me go ahead with this implementation. if you can show me a sample, i will be the happiest person in the world.
PS : I cannot use midl and idl files , please dont question me on the same, as that is a business decision. and it will always over ride the technical decisions
Any help appreciated and a hundres thanks 
Regards
Althaf M
-
April 16th, 2010, 09:55 AM
#2
Re: EventHandling in COM Using IDispatch with out using idl and midl
Not sure what your question is.
Are you trying to implement a COM server with connection points?
Or are you trying to consume a COM server implemented with connection points?
-
April 16th, 2010, 10:08 AM
#3
Re: EventHandling in COM Using IDispatch with out using idl and midl
I am trying to consume the com server, which is implemented with connection points.
basically to handle events from the instances..
thanks
althaf
-
April 16th, 2010, 11:38 AM
#4
Re: EventHandling in COM Using IDispatch with out using idl and midl
You'd give a try with oleview tool. It's able to load the server's typelibrary and show corresponding idl, which could be copied and used later as you wish.
Best regards,
Igor
-
April 16th, 2010, 01:01 PM
#5
Re: EventHandling in COM Using IDispatch with out using idl and midl
i got the answer , thank you all for you replies..
it can be implemented using IDispEventSimpleImpl and _ATL_FUNC_INFO structures
msdn gives a good example too
thanks & regards
Althaf
-
April 26th, 2010, 01:23 PM
#6
Re: EventHandling in COM Using IDispatch with out using idl and midl
I have done with the IDispEventSimpleImpl.. but my events are not getting called i think..
i think there is some thing i am missing... may be some thing related to the cookies. I wonder whether iDispatch is used mainly for the browsers ? or atleast IDispEventImpl is used for that ?
can any one please explain with a sink sample code of implementing IDispEventSimpleImpl.
thanks
althaf
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|