Solved

VC++ Autoserver & RegisterActiveObject

Posted on 1997-07-04
2
697 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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now