VC++ Autoserver & RegisterActiveObject


I'm trying to get an automation server to work using
VC++ 4.0.

I'm getting the automation server connections to work;  
if I could get a copy of the server initialized manually to be the copy which a client used, I'd be happy.  The one example which msoft provides is that of their dialog-based
calculator;  the code in the client can be  copied verbatim to the constructor for the mainframe class of a normal application, and appears to work.  It tries to pick up an
existing copy of the server and creates one if that fails.


The code which the server needs would appear to be something like:

HRESULT  regret;
CLSID bclsid;
CLSID  *clsptr;
      
clsptr = new CLSID;
regret = CLSIDFromProgID(OLESTR("IISERVER.AUTOMGTD"),
      clsptr );

m_dwRegister = 0;

regret = RegisterActiveObject( GetInterface (&IID_IUnknown),
           *clsptr, NULL, &m_dwRegister) ;

which doesn't work when transposed to the tail end of the constructor for the mainframe class of the server.  

The call to RegisterActiveObject returns an invalid argument code.  The  GetInterface (&IID_IUnknown) call and its argument compile but, other than that, appear to simply be something being called down out of the sky.  Help draws a blank on it.  No other reference to IID_IUnknown appears in the mcalc example.


medvedAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jabaCommented:
You sure you call AfxOleInit ? Do you class declared as OLE automation object ? RegiaterActiveObject registering object as active OLE object for it class. only. Try generate simple MFC application with automation support and look to InitInstance code
0
belovCommented:
I think your problem is in placing RegisterActiveObject
in constructor of the mainframe class. To that
moment not all internal initialization is done, and
GetInterface fails, causing RegisterActiveObject
to report invalid parameter. Move that call
to the place where your mainframe creation
is finished. Note that msoft example invokes
that call _after_ all window initialization is complete.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.