Design Question
-
Hi, I want to create an application which will have three "services" (not necessarily NT services). I need fast and frequent IPC calls, and think that COM is probably the way forward for this. One of these services will need to communicate with the two others, and those two others will need to know about the first. When defining the interfaces for these services, should I create a single IDL that defines all three? Surely this will reduce include complexity? Am I correct in thinking that the best way to do so is to derive from IUnknown - or should I be aiming at IDispatch? Having defined that IDL, is the best way to attempt to compile that into a .tlb and import it in the other projects? I'm relatively new to COM so please excuse my lack of knowledge... Thanks in advance for any advice or suggestions you can give me. I am trying to work my way through Essential COM while programming with ATL7 - something which doesn't exactly ease the process of getting into COM :) -- Simon Steele Programmers Notepad - http://www.pnotepad.org/
-
Hi, I want to create an application which will have three "services" (not necessarily NT services). I need fast and frequent IPC calls, and think that COM is probably the way forward for this. One of these services will need to communicate with the two others, and those two others will need to know about the first. When defining the interfaces for these services, should I create a single IDL that defines all three? Surely this will reduce include complexity? Am I correct in thinking that the best way to do so is to derive from IUnknown - or should I be aiming at IDispatch? Having defined that IDL, is the best way to attempt to compile that into a .tlb and import it in the other projects? I'm relatively new to COM so please excuse my lack of knowledge... Thanks in advance for any advice or suggestions you can give me. I am trying to work my way through Essential COM while programming with ATL7 - something which doesn't exactly ease the process of getting into COM :) -- Simon Steele Programmers Notepad - http://www.pnotepad.org/
Simon Steele wrote: Hi, I want to create an application which will have three "services" (not necessarily NT services). I need fast and frequent IPC calls, and think that COM is probably the way forward for this. One of these services will need to communicate with the two others, and those two others will need to know about the first. When defining the interfaces for these services, should I create a single IDL that defines all three? Surely this will reduce include complexity? Am I correct in thinking that the best way to do so is to derive from IUnknown - or should I be aiming at IDispatch? Having defined that IDL, is the best way to attempt to compile that into a .tlb and import it in the other projects? I would go for a single IDL and .TLB because there are inter-dependencies between the interfaces, as it seems it is your first ATL project. About the IDispatch, using ATL, I would definitively recommend you to declare your interfaces as dual, so they are exposed both as custom interfaces (derive directly from IUnknown) and have the IDispatch implemented too. Take care and only use automation types, this makes things easier for your clients. You'll never know when your COM object will be used from scripting clients or beginner VB programmers, and God knows why, they find IDispatch easier... The ATL COM wizard have an option that generates the dual interfaces declaration and the IDispatch implementation for you, so, normally this is a no-brainer. Q261186 - Computer Randomly Plays Classical Music
-
Hi, I want to create an application which will have three "services" (not necessarily NT services). I need fast and frequent IPC calls, and think that COM is probably the way forward for this. One of these services will need to communicate with the two others, and those two others will need to know about the first. When defining the interfaces for these services, should I create a single IDL that defines all three? Surely this will reduce include complexity? Am I correct in thinking that the best way to do so is to derive from IUnknown - or should I be aiming at IDispatch? Having defined that IDL, is the best way to attempt to compile that into a .tlb and import it in the other projects? I'm relatively new to COM so please excuse my lack of knowledge... Thanks in advance for any advice or suggestions you can give me. I am trying to work my way through Essential COM while programming with ATL7 - something which doesn't exactly ease the process of getting into COM :) -- Simon Steele Programmers Notepad - http://www.pnotepad.org/
Simon Steele wrote: One of these services will need to communicate with the two others, and those two others will need to know about the first. If each service is a COM object, then you'll have 3 idl files. Reusing idl file from one COM service into another is not an option since GUID, LIBID, CLSID, IID would be the same. It's sad MIDL is really limited when it comes to sharing idl interfaces, although you have the
import
andimportlib
statements. Simon Steele wrote: Thanks in advance for any advice or suggestions you can give me. I am trying to work my way through Essential COM while programming with ATL7 - something which doesn't exactly ease the process of getting into COM I recommend to stay low-level. You'll get code skeletons from the book "Inside COM" MS PRESS, which I recommend. And this source code doesn't obfuscate at all what is done, unlike ATL. ATL is fast for coming up with COM servers, but the learning curve is huge (in fact, you won't get your own ATL COM server running without actually hacking what ATL does, which requires huge time when you don't know it). That said, I can't come up at the moment with a decent listing on CodeProject who would have just that, but beware of code filled with macros...
How low can you go ?
(MS rant) -
Simon Steele wrote: One of these services will need to communicate with the two others, and those two others will need to know about the first. If each service is a COM object, then you'll have 3 idl files. Reusing idl file from one COM service into another is not an option since GUID, LIBID, CLSID, IID would be the same. It's sad MIDL is really limited when it comes to sharing idl interfaces, although you have the
import
andimportlib
statements. Simon Steele wrote: Thanks in advance for any advice or suggestions you can give me. I am trying to work my way through Essential COM while programming with ATL7 - something which doesn't exactly ease the process of getting into COM I recommend to stay low-level. You'll get code skeletons from the book "Inside COM" MS PRESS, which I recommend. And this source code doesn't obfuscate at all what is done, unlike ATL. ATL is fast for coming up with COM servers, but the learning curve is huge (in fact, you won't get your own ATL COM server running without actually hacking what ATL does, which requires huge time when you don't know it). That said, I can't come up at the moment with a decent listing on CodeProject who would have just that, but beware of code filled with macros...
How low can you go ?
(MS rant)If I split the interface and class definitions, then surely I can have a single .IDL file for the three which defines the interfaces? Then each can implement classes and libraries which contain implementations of those interfaces? As I said I'm new to this, but it does seem to be hinted at in the book I'm reading. __Stephane Rodriguez__ wrote: You'll get code skeletons from the book "Inside COM" MS PRESS, I'm trying to make my way through Essential COM by Don Box which is great, but the shear amount of code to do this stuff without ATL seems incredible! -- Simon Steele Programmers Notepad - http://www.pnotepad.org/
-
Simon Steele wrote: Hi, I want to create an application which will have three "services" (not necessarily NT services). I need fast and frequent IPC calls, and think that COM is probably the way forward for this. One of these services will need to communicate with the two others, and those two others will need to know about the first. When defining the interfaces for these services, should I create a single IDL that defines all three? Surely this will reduce include complexity? Am I correct in thinking that the best way to do so is to derive from IUnknown - or should I be aiming at IDispatch? Having defined that IDL, is the best way to attempt to compile that into a .tlb and import it in the other projects? I would go for a single IDL and .TLB because there are inter-dependencies between the interfaces, as it seems it is your first ATL project. About the IDispatch, using ATL, I would definitively recommend you to declare your interfaces as dual, so they are exposed both as custom interfaces (derive directly from IUnknown) and have the IDispatch implemented too. Take care and only use automation types, this makes things easier for your clients. You'll never know when your COM object will be used from scripting clients or beginner VB programmers, and God knows why, they find IDispatch easier... The ATL COM wizard have an option that generates the dual interfaces declaration and the IDispatch implementation for you, so, normally this is a no-brainer. Q261186 - Computer Randomly Plays Classical Music
Daniel Turini wrote: About the IDispatch, using ATL, I would definitively recommend you to declare your interfaces as dual Thanks, I'll try it. I'm only working on experimental projects at the moment so it doesn't matter too much if I get it wrong and need to start again. But you know how these experimental projects suddenly become sold products! Some of this stuff is really clever, I am being repeatedly amazed :omg: Do I need to separate the interfaces from the classes in this separate IDL file? I might want to create multiple objects that expose the same interface and am not entirely clear on how to do this sanely! Thanks again for your help, -- Simon Steele Programmers Notepad - http://www.pnotepad.org/
-
If I split the interface and class definitions, then surely I can have a single .IDL file for the three which defines the interfaces? Then each can implement classes and libraries which contain implementations of those interfaces? As I said I'm new to this, but it does seem to be hinted at in the book I'm reading. __Stephane Rodriguez__ wrote: You'll get code skeletons from the book "Inside COM" MS PRESS, I'm trying to make my way through Essential COM by Don Box which is great, but the shear amount of code to do this stuff without ATL seems incredible! -- Simon Steele Programmers Notepad - http://www.pnotepad.org/
Simon Steele wrote: If I split the interface and class definitions, then surely I can have a single .IDL file for the three which defines the interfaces? Then each can implement classes and libraries which contain implementations of those interfaces? As I said I'm new to this, but it does seem to be hinted at in the book I'm reading. Yes, at least in theory, and it will even compile. But I am not sure it will run. I had this problem, and the .tlb was not including the idl stuff I was including in the main idl. So it was ok for compilation time. But only for compilation time. Simon Steele wrote: the shear amount of code to do this stuff without ATL seems incredible! That's a fake. May be I publish COM skeletons sometimes in the future so you figure out it's damn light, easy, DEBUGGABLE (unlike ATL macros), neat and reusable. (as you can see, I am not a big fan of ATL ;P).
How low can you go ?
(MS rant) -
Simon Steele wrote: If I split the interface and class definitions, then surely I can have a single .IDL file for the three which defines the interfaces? Then each can implement classes and libraries which contain implementations of those interfaces? As I said I'm new to this, but it does seem to be hinted at in the book I'm reading. Yes, at least in theory, and it will even compile. But I am not sure it will run. I had this problem, and the .tlb was not including the idl stuff I was including in the main idl. So it was ok for compilation time. But only for compilation time. Simon Steele wrote: the shear amount of code to do this stuff without ATL seems incredible! That's a fake. May be I publish COM skeletons sometimes in the future so you figure out it's damn light, easy, DEBUGGABLE (unlike ATL macros), neat and reusable. (as you can see, I am not a big fan of ATL ;P).
How low can you go ?
(MS rant)__Stephane Rodriguez__ wrote: That's a fake. May be I publish COM skeletons sometimes in the future so you figure out it's damn light, easy, DEBUGGABLE (unlike ATL macros), neat and reusable. (as you can see, I am not a big fan of ATL ). Agree entirely. Please do publish your code :) Len Holgate www.jetbyte.com The right code, right now.