?
Solved

VC++ Autoserver & RegisterActiveObject

Posted on 1997-07-04
2
Medium Priority
?
747 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.
Suggested Courses

762 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