hey guys.. i found out my mistake. I was using CLSCTX_INPROC_SERVER in
CoCreateInstance(). When i replaced it with CLSCTX_LOCAL_SERVER,
cocreateinstance() was successful. But now i am facing another problem.
I have defined a method in my interface as.
the method returns S_OK, but the value in ReturnValue is some garbage value.
Is the process of creating a COM Service same as that of COM DLL? I created a
COM service and implemented an interface with an addnumbers() method. THen
i registered that service as a windows service. The problem i encounter is in
creating a client. When i had created a com dll, my client simply imported
the header file of the com dll and i also defined some GUID's. Then with a
call to CoCreateInstance (IFirst_ATL being my interface) i could directly
call the addnumbers() method as follows and i succeeded.
hr = CoCreateInstance( CLSID_First_ATL, NULL, CLSCTX_INPROC_SERVER,
IID_IFirst_ATL, (void**) &IFirst_ATL);
hr = IFirstATL->AddNumbers(5, 7, &ReturnValue);
But when i do the same thing by building an ATL service. then the above
methods fail. Please advice me in this regard. Let me know if u need any
other information.
"Brian Muth" wrote:
"Rohit Kumar" <RohitKumar@discussions.microsoft.com> wrote in message
news:3E7C356A-7BA9-47E1-BA67-F0892268F4B4@microsoft.com...
Can anyone please help me or give me some sample code? I need to create an
ATL COM service (not a DLL) which has a dummy interface.. say. add 2
numbers.. After creating the service, i want to register it as a windows
service. Then i want to create a client which connects to this service and
uses the interface.. (adds 2 numbers) I have searched online and there is
not
a decent article which explains the process step by step... Any help in
this
regard will be very useful.
Any sample code for creating and using the service will be helpful...
Thanks in advance!!!!
Usually security related questions arise along the way, and I strongly
suggest it's best to purchase a book. I believe both of the following have
step-by-step examples, and you can confirm this at your local bookstore:
http://tinyurl.com/38m7hj
http://tinyurl.com/39tbg8
I assume you have already built an ATL COM DLL, as described here:
http://msdn2.microsoft.com/en-us/library/599w5e7x(VS.80).aspx
If you simply choose to build a service, rather than a DLL, what problems do
you run into?
Brian