ATL COM Service
-
Can anyone please help me or give me some sample code? I need to create an ATL COM service 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. Thanks in advance!!!!
-
Can anyone please help me or give me some sample code? I need to create an ATL COM service 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. Thanks in advance!!!!
Hi, Create a ATL Project and choose service(EXE) type. The Wizard will generate code for you. Add an ATL Simple object Like as you add ATL Simple Object to any ATL Project. Implement your dummy methods or what ever you want.# Build the project, Go to command prompt and type -i to Install it as a Windows service. In Client you can do a #import on this executable and you can use your dummay interface and methods. Cheers, Suresh
-
Hi, Create a ATL Project and choose service(EXE) type. The Wizard will generate code for you. Add an ATL Simple object Like as you add ATL Simple Object to any ATL Project. Implement your dummy methods or what ever you want.# Build the project, Go to command prompt and type -i to Install it as a Windows service. In Client you can do a #import on this executable and you can use your dummay interface and methods. Cheers, Suresh
I have succeded in creating a service with a dummy interface.... Then in the client I have imported the header file of the service and defined the GUID's. Suppose i have an interface IFirst_ATL and it has a method addnumbers(), then how can i access that method. I am trying to create an instance of the service by hr = CoCreateInstance( CLSID_First_ATL, NULL, CLSCTX_INPROC_SERVER, IID_IFirst_ATL, (void**) &IFirst_ATL); IFirstATL->AddNumbers(5, 7, &ReturnValue); but this is not giving me the desired results. Can you please provide me a sample and successfully running code for accessing the methods of the service? Thanks in Advance!
-
I have succeded in creating a service with a dummy interface.... Then in the client I have imported the header file of the service and defined the GUID's. Suppose i have an interface IFirst_ATL and it has a method addnumbers(), then how can i access that method. I am trying to create an instance of the service by hr = CoCreateInstance( CLSID_First_ATL, NULL, CLSCTX_INPROC_SERVER, IID_IFirst_ATL, (void**) &IFirst_ATL); IFirstATL->AddNumbers(5, 7, &ReturnValue); but this is not giving me the desired results. Can you please provide me a sample and successfully running code for accessing the methods of the service? Thanks in Advance!
Seems that i have found out the problem.. I replaced CLSCTX_INPROC_SERVER with CLSCTX_LOCAL_SERVER in CoCreateInstance(). But now i am facing a different problem. I have defined a method in my interface as. STDMETHODIMP CFirst_ATL::AddNumbers(LONG x, LONG y, LONG* z) { *z = x + y; return S_OK; } when i try calling this method from client as hr = IFirst_ATL->AddNumbers(5, 7, &ReturnValue); the method returns S_OK, but the value in ReturnValue is some garbage value. Can anyone please advice where have i went wrong? Thanks!