Click to See Complete Forum and Search --> : Please ! How to limit an activex server to a single instance
C.Gimenez
April 9th, 1999, 04:54 AM
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
Mike Wild
April 9th, 1999, 08:33 AM
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
C.Gimenez
April 9th, 1999, 08:38 AM
Sorry, I use an MFC application with automation enabled... Of course I'm really interested by a sample !!
Mike Wild
April 9th, 1999, 08:48 AM
I would say your application is not Doc-Based, isn't it. OK I send you the stuff!
But need you E-Mail
Mike
Dave Lorde
April 9th, 1999, 08:59 AM
Use a mutex instead of FindWindow.
Dave
Mike Wild
April 9th, 1999, 09:04 AM
Othervice I can't send you the stuff.
You can send me you adress.
Mike
Rajaraman
April 27th, 1999, 01:13 PM
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.
raman_raja@hotmail.com
Rajaraman
April 27th, 1999, 01:49 PM
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
MoMoPi
April 28th, 1999, 08:41 AM
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).
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.