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
Solved

Work with remote COM+ server who implement IUnknown

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

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…
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

808 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