I've written a tiny automation server in VC that exposes an automation
interface, let's call it IFoo. The methods in IFoo are implemented in the
server's CDocument-derived class.

I've written a tiny VB client that instantiates one of these 'things', calls
the one method defined via this interface, and it all works smooth as silk.
So far, so good. Because this works, the server MUST be registered
correctly, surely?

Now I'm trying to write a tiny VC client to do the same as the VB client,
but I've come unstuck.

I've #imported the .tlb file and am trying to use the smart pointer created
therein, like this:

        IFooPtr pFoo ;

        ::CoInitialize(NULL);

        if (SUCCEEDED(pFoo.CreateInstance(_uuidof(IFoo) ) ) )
        {
                pFoo->Bar(...);

The problem is, CreateInstance() returns (rather, the smart pointer records
when the function fails) REGDB_E_CLASSNOTREG, described by MSDN as follows:

"A specified class is not registered in the registration database. Also can
indicate that the type of server you requested in the CLSCTX enumeration is
not registered or the values for the server types in the registry are
corrupt. "

Now, since CreateInstance() on a smart pointer doesn't give me a choice of
CLSCTX_ constant, that isn't my problem; I traced into the code and it uses
CLSCTX_ALL as it happens.

The problem, I see from tracing the code, is when it tries to call
CoCreateInstance() asking for IUnkown - then it returns this code and bombs
out.

But I don't understand why, if the VB client can use it quite happily?

I've hit so many brick walls in coding these last few weeks I feel like a
crash test dummy!

--
Jason Teagle
[EMAIL PROTECTED]




Reply via email to