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

    Please ! How to limit an activex server to a single instance

    Hi there,
    I can't find to limit a com enabled application but I would like to limit the number of instances to only ONE. (This is intended to be a central process hold state of several informations).

    Problem is : the traditional method using FindWindow and returning FALSE from InitInstance works ok except when a script language (like VBSCRIPT) tries to use a CreateObject on it.

    I've tried to do the same with VB5 and it works fine, thus if I can do it with VB I could to it with VC++

    Thanks


  2. #2
    Join Date
    Apr 1999
    Posts
    43

    Re: Please ! How to limit an activex server to a single instance

    Your informations are a little bit poor. What do you use: MFC/ATL/Raw COM? What kind of server is it: Automation/Dual? For MFC I can send you the stuff I have with a runable sample!

    Mike


  3. #3
    Join Date
    Apr 1999
    Posts
    2

    Re: Please ! How to limit an activex server to a single instance

    Sorry, I use an MFC application with automation enabled... Of course I'm really interested by a sample !!


  4. #4
    Join Date
    Apr 1999
    Posts
    43

    Re: Please ! How to limit an activex server to a single instance

    I would say your application is not Doc-Based, isn't it. OK I send you the stuff!
    But need you E-Mail

    Mike


  5. #5
    Join Date
    Apr 1999
    Posts
    383

    Re: Please ! How to limit an activex server to a single instance

    Use a mutex instead of FindWindow.

    Dave


  6. #6
    Join Date
    Apr 1999
    Posts
    43

    Need your E-Mail

    Othervice I can't send you the stuff.
    You can send me you adress.

    Mike



  7. #7
    Join Date
    Apr 1999
    Location
    Delhi, India
    Posts
    32

    Re :How to limit an activex server to a single instance

    Dear Mike,
    I have created an automation server and client using MFC. I call CreateDispatch() from my client to launch the server. The problem is, every instance of the client launches a fresh copy of the server. I want to limit the server to a single instance, to which all the clients should connect.
    While it is easy to use FindWindow() or a mutex to prevent the server from launching the second copy, my client applications - except the first instance - are unable to communicate with the server. Can you please give some tips?...
    Thanks a lot.
    [email protected]


    Rajaraman

  8. #8
    Guest

    Re: Please ! How to limit an activex server to a single instance

    Hi,

    I have had similar problems before.

    If i remember right I registered server application as an active server
    (running object table (ROT) of OLE)
    using functions below:

    RegisterActiveObject - registering.
    RevokeActiveObject - unregistering when server was shutting down.

    Then in client I first tried to attach to running server via
    AttachDispatch, if that failed I knew that server was not running and
    I used CreateDispatch.

    That helped in Automation.

    Regards

    Mikko




  9. #9
    Join Date
    Apr 1999
    Posts
    31

    Re: Please ! How to limit an activex server to a single instance


    I use CoRegisterClassObject(*,
    static_cast<IUnknown*>(pIFactory),
    CLSCTX_LOCAL_SERVER,// it depends on your COM
    REGCLS_SINGLEUSE,
    &dwRegister);
    also use ::CoRevokeClassObject(dwRegister) ; //to stop it.

    I hope this works,(It's working on my project).



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