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. COM
  4. How to close a COM Server Process from Client? Thank you!

How to close a COM Server Process from Client? Thank you!

Scheduled Pinned Locked Moved COM
questionc++comsysadmin
5 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.
  • B Offline
    B Offline
    Best Kiluyar
    wrote on last edited by
    #1

    :-OHi, all experts: I tried to create a COM local server and a client using win32 console application winzard in VC++ 6. When the client started up, it active the server automatically. The client also connected to server and called interface functions successfully. :((But, how can I terminate the server from client, before the client ended itselt?:^) Thanks a lot!:):):-D:-D REMY

    S 1 Reply Last reply
    0
    • B Best Kiluyar

      :-OHi, all experts: I tried to create a COM local server and a client using win32 console application winzard in VC++ 6. When the client started up, it active the server automatically. The client also connected to server and called interface functions successfully. :((But, how can I terminate the server from client, before the client ended itselt?:^) Thanks a lot!:):):-D:-D REMY

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      With COM objects you shouldn't need to take any explicit action to terminate the server beyond the normal reference counting calls to AddRef and Release you (and/or your smart pointers) do on the object's interfaces. Steve

      B 1 Reply Last reply
      0
      • S Stephen Hewitt

        With COM objects you shouldn't need to take any explicit action to terminate the server beyond the normal reference counting calls to AddRef and Release you (and/or your smart pointers) do on the object's interfaces. Steve

        B Offline
        B Offline
        Best Kiluyar
        wrote on last edited by
        #3

        Yes. I wrote the 'Release' member for COM SEVER just as following: ULONG CExeComServerConsole0_0::Release() { long nRefCount = InterlockedDecrement(&m_nRef) ; if (nRefCount == 0) delete this; return nRefCount; } But, How can I teminate the server process?:):):):)

        S 1 Reply Last reply
        0
        • B Best Kiluyar

          Yes. I wrote the 'Release' member for COM SEVER just as following: ULONG CExeComServerConsole0_0::Release() { long nRefCount = InterlockedDecrement(&m_nRef) ; if (nRefCount == 0) delete this; return nRefCount; } But, How can I teminate the server process?:):):):)

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          Ok, you’re talking from the point of view of implementing the server, that wasn't clear in your post. Typically a global reference count is maintained which all implemented COM object increment when they're constructed and decrement when they're destructed. IClassFactory::LockServer also increments or decrements it based on its parameter - References on class factories should not influence this count. When the count transitions to zero the server typically wait for a timeout - If there is no activity and the timeout expires CoSuspendClassObjects is called and we arrange for the application to exit. In short it's complicated. Use ATL and you don't have to worry about any of this. Steve

          B 1 Reply Last reply
          0
          • S Stephen Hewitt

            Ok, you’re talking from the point of view of implementing the server, that wasn't clear in your post. Typically a global reference count is maintained which all implemented COM object increment when they're constructed and decrement when they're destructed. IClassFactory::LockServer also increments or decrements it based on its parameter - References on class factories should not influence this count. When the count transitions to zero the server typically wait for a timeout - If there is no activity and the timeout expires CoSuspendClassObjects is called and we arrange for the application to exit. In short it's complicated. Use ATL and you don't have to worry about any of this. Steve

            B Offline
            B Offline
            Best Kiluyar
            wrote on last edited by
            #5

            Thank you! Steve I wanted to know more about the auto-ending of Server. I created a ATL EXE COM SERVER and used a client to conneted and disconnected it. After a moment, in system process list, the ATL EXE process disappeared. But, I didn't know when the CoSuspendClassObjects was called. Could you tell me more details. I'm learning COM/ATL. Thank you very much! Sincerely REMY:)

            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