Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Work with remote COM+ server who implement IUnknown

Posted on 2001-07-09
1
Medium Priority
?
459 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 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

810 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