Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. ATL COM Service

ATL COM Service

Scheduled Pinned Locked Moved ATL / WTL / STL
c++comhelptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Janma
    wrote on last edited by
    #1

    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!!!!

    S 1 Reply Last reply
    0
    • J Janma

      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!!!!

      S Offline
      S Offline
      sthotakura
      wrote on last edited by
      #2

      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

      J 1 Reply Last reply
      0
      • S sthotakura

        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

        J Offline
        J Offline
        Janma
        wrote on last edited by
        #3

        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!

        J 1 Reply Last reply
        0
        • J Janma

          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!

          J Offline
          J Offline
          Janma
          wrote on last edited by
          #4

          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!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups