[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VC++ Autoserver & RegisterActiveObject

Posted on 1997-07-04
2
Medium Priority
?
782 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 learn how to clear a vector as well as how to detect empty vectors in C++.

873 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