Solved

Work with remote COM+ server who implement IUnknown

Posted on 2001-07-09
1
450 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MSVCR80.dll crash 2 139
Handle Exceptions during instantiation 28 415
Focus not getting shifted out of  editbox 2 62
draw a Christmas tree by using a nested loop? 26 61
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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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++.

786 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