?
Solved

Work with remote COM+ server who implement IUnknown

Posted on 2001-07-09
1
Medium Priority
?
455 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
[X]
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
1 Comment
 

Accepted Solution

by:
rtenhove earned 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

771 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