CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009
    Posts
    4

    CoCreateInstance and COM server

    Hi!

    I made an existing (GUI) application a COM server.
    I access this server by a simple test program using CoCreateInstance there.
    This works, i.e. if the GUI application is not started it gets started, if it is already started, there will not be an additional instance of the application and the information I want gets retrieved correctly.
    But:
    If I call CoCreateInstance several times in my test application, then each time it *does* create an additional instance of my COM server and this is bad.
    So what could be the reason?
    What throws the interface information away (although the COM server is still running)?
    Has something to be done in the COM server concerning this?
    As it is an first version, I did not do anything in LockServer implementation yet (IClassFactory), just return S_OK.
    Remark: Of course I should reuse the pointer I get from the first CoCreateInstance, but why do several CoCreateInstance calls corrupt the SCM?

    Thanks,
    ueberdu.

  2. #2
    Join Date
    Aug 2009
    Posts
    4

    Re: CoCreateInstance and COM server

    I found the solution.
    So for all interested or having a similiar problem:
    When calling CoRegisterClassObject in the COM server code,
    the flags have to include REGCLS_MULTIPLEUSE.
    Otherwise it behaves as described by me.

    ueberdu.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured