Solved

VC++ Autoserver & RegisterActiveObject

Posted on 1997-07-04
2
707 Views
Last Modified: 2008-03-17

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.


0
Comment
Question by:medved
2 Comments
 
LVL 3

Expert Comment

by:jaba
ID: 1164286
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
 
LVL 1

Accepted Solution

by:
belov earned 100 total points
ID: 1164287
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

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question