November 30, 2015
Hot Topics:

SkDCOMbridge : COM/DCOM Handler Object

  • August 4, 2000
  • By Shai Korianski
  • Send Email »
  • More Articles »


The object retrieves a valid pointer to a local COM object's interface or a remote DCOM object's interface simply by calling its main method ('getInterfacePointer') with the object's and interface's NAME or ID. This class saves you lots of time by doing all the name<->ID/CLSID conversion and handling all needed Window's APIs by itself while the object's input is simply a reference to what you want (object,interface) and the returning output is a valid pointer to it. Many times there is a need to create a wrapper for a given interface. This can be done be done using this object in two ways,
  1. Simply inherit the object, call the main function on your initialization method and use the protected '_pInterface' member in your 'raaping' methods. That's it!
  2. Create an instance of this object in your class
  3. Use the main method ('getInterfacePointer') for retrieving an interface and keep the interface in a local member.

The code here is also a great example of how to use Windows API for handling COM/DCOM objects.

Method Descriptions and Definitions

  • Main function : getInterfacePointer


    int getInterfacePointer(IUnknown **ppInterface,
                            void *comObjectInfo,
                            void *interfaceObjectInfo,
                            int flags = SKDCOM_COMINFO_NAME 
                                      | SKDCOM_INTERFACEINFO_NAME,
                            void *computerName = NULL,
                            COAUTHINFO *pAuthInfo = NULL);


    ppInterface [out] Pointer for interface pointer in which the method should enter the desired interface's pointer.
    comObjectInfo [in] COM object's description. can be name [OLE string !] or CLSID.
    interfaceObjectInfo [in] Interface's description. can be name [OLE string] or IID.
    flags [in] flags which describes 'comObjectInfo' and 'interfaceObjectInfo'

    use SKDCOM_COMINFO_NAME - when 'comObjectInfo' is object's a name (such as 'MyCOM.Engine')

    SKDCOM_COMINFO_CLASID - when 'comObjectInfo' is object's an CLSID.

    SKDCOM_INTERFACEINFO_NAME - when 'interfaceObjectInfo' is a name (such as 'MyCOM.Engine.iXYZ')

    SKDCOM_INTERFACEINFO_REFIID - when 'interfaceObjectInfo' is an IID

    each flag value should be a logical or of 'comObjectInfo' and 'interfaceObjectInfo' descriptions.

    default value is name for both.
    computerName [in] points to a computer name. DCOM ONLY. if NULL object uses COM.
    pAuthInfo [in] points to a 'COAUTHINFO' object. DCOM ONLY. if NULL object uses default security parameters.


  • GetCLSID Function


    void getCLSID(CLSID *clsid) const;


    clsid [out] Pointer to a CLSID instance which will recieve object's CLSID value.


    Retrieves object's CLSID (even if main method was called with name for object's description)

    Return Value

    • SKDCOM_ERROR_CLSID_NAME_NOT_FOUND - object's name was not found.
    • SKDCOM_ERROR_CLSID_NOT_FOUND - object's ID was not found.
    • SKDCOM_ERROR_IID_NOT_FOUND - interface's ID was not found.
    • SKDCOM_ERROR_IID_NAME_NOT_FOUND - interface's name was not found.
    • SKDCOM_ERROR_FAIL - function failed.
    • SKDCOM_SUCCESS - success. output parameter is valid.

  • getIID Function


    void getIID(IID *iid) const;


    iid [out] Pointer to an IID instance which recieve interface's IID value.


    Retrieves interface's IID (even if main method was called with name for interface description)

  • getLastRetrivedInterface Function


    void getLastRetrivedInterface(IUnknown **ppInterface) const;


    ppInterface [out] Points to an interface pointer


    Enters last retrived pointer to 'ppInterface'.

  • getLastSystemError


    HRESULT getLastSystemError() const;


    No parameters

    Return Value

    Returns system last error (Window's API error code).


Download source - 6 Kb


Date Posted: August 4, 2000

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel