Link to home
Start Free TrialLog in
Avatar of benacler
benacler

asked on

embedding a COM Server in an already existing service

Ok, a question to the gurus out there, I'll make a short description of what I want to do, let's see if I'm on the right way or not...
I'm relatively new on COM, I understand how the layer works and the benefits as well as the general development concepts. My scenario follows: I've an existing application that runs as a Windows service, the application is block built, that means I already have a C++ SDK to interact with the core DLLs, I'm also looking about integrating Python, that's pretty simple, I've just to write a proxy Layer on my classes/functions, that doesn't scare me. I was thinking about the idea of giving COM and Automation support on the server itself, and here comes the doubts.
Is there a way to embed a COM/DCOM server inside my existing applicaiton ? Out-of-process and distributed servers have some kind of on-call activation managed by the SCM inside windows, what I really like to do, if that's possible, to have several methods available generally that may fail if the server is not running (or even run it on demand), but include the com logic directly inside my server. I'm almost sure I can write a standalone proxy component that interact with a local named pipe (or socket) to my main service, but this may cause me a big headache implementing my custom marshalling/unmarshalling on the server itself.
I hope what I asked is clear, and if possible, could some one point me to a working example/documentation ?

cheers.

Avatar of jkr
jkr
Flag of Germany image

It'd rather go the way to not use the same module as a server, since that might cause problems security-wise (the same image might have to run in two different contexts)

>>Is there a way to embed a COM/DCOM server inside my existing applicaiton ?

Ther are, but, I wouldn't do that, rather split the basic code into DLLs that serve as a COM service and also can be used by your application for th aforementioned reasons. This is just a precaution, though.

What is your service actually supposed to do?
Avatar of benacler
benacler

ASKER

>> It'd rather go the way to not use the same module as a server, since that might cause problems security-wise (the same image might have to run in two different contexts)

I'm talking exactly about this, I don't want to run the server in two different contexts, but I would like to inject the COM calls into an already running process. Maybe I was not clear...

>> Ther are, but, I wouldn't do that, rather split the basic code into DLLs that serve as a COM service and also can be used by your application for th aforementioned reasons. This is just a precaution, though.

Again, choosing this way requires some sort of IPC betweeen the DLLs, that will run in two different contexts... that's exacty what I would like to avoid

>> What is your service actually supposed to do?
Some sort of client/server communication to process tasks, but this is out of scope, my question is general.
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OH, BTW, as a starting point: http://msdn2.microsoft.com/en-us/library/74y2334x(VS.80).aspx ("ATL Services")

(I might be carrying coals to Newcastle, though ;o)
so it seams possible. Any example without ATL ?
A COM server without ATL? ;o) Yikes, that is going to be quite difficult. Well, there is one at http://msdn2.microsoft.com/en-us/library/a2ht8e6d.aspx ("DCOM Sample: Calls COM Object in Windows Service from Multiple Clients"), but even the sample clients are either ATL or MFC...