Solved

Work with remote COM+ server who implement IUnknown

Posted on 2001-07-09
1
444 Views
Last Modified: 2011-09-20
How can I use the function CoCreateInstanceEx to create a new remote instance of a COM+ object who implements IUnknown?.
I try this and I receive the message error:Such interface not suported.
0
Comment
Question by:Nedelescu
1 Comment
 

Accepted Solution

by:
rtenhove earned 50 total points
ID: 6270750
HRESULT
CreateInstanceOnServer
    (
    wchar_t         * pwszRemoteName,
    REFCLSID          rclsid,     // Class identifier of the object to create
    REFIID            riid,       // Identifier of the interface to return
    LPVOID          * ppv         // Returned interface pointer
    )
{
/////////////////////////////////////////////////////////////////////////
    // Prepare a description of the remote server.
    //
    HRESULT           hres;
    COSERVERINFO      si;
    COSERVERINFO    * psi = 0;  // default to "no server info specified"
    if ( pwszRemoteName != 0 && ::wcslen( pwszRemoteName ) > 0 )
    {
        si.dwReserved1 = 0;
        si.pwszName    = pwszRemoteName;    // Server name
        si.pAuthInfo   = 0;                 // Default authority
        si.dwReserved2 = 0;
        psi = &si;
    }
    /////////////////////////////////////////////////////////////////////////
    // Create the designated object type on the server.  In order to
    // optionally specify the remote server, we must use CoCreateInstanceEx.
    //
    MULTI_QI          rgmq[ 1 ];
    rgmq[ 0 ].pIID = &riid;
    rgmq[ 0 ].pItf = 0;
    rgmq[ 0 ].hr   = S_OK;

    hres = ::CoCreateInstanceEx(
        rclsid,                         // Identifier of class to create
        0,                              // Pointer to outer unknown (aggr.)
        CLSCTX_SERVER,                  // Class creation context
        psi,                            // Server information (if any)
        N_ARRAY_ELEMENTS( rgmq ),       // # of interfaces to query
        rgmq );                         // Interfaces to get, + results

    if ( SUCCEEDED( hres ) && ppv != 0 )
        *ppv = (LPVOID) (rgmq[ 0 ].pItf);

    return hres;
}
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

747 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

12 Experts available now in Live!

Get 1:1 Help Now