Note that there are some explanatory texts on larger screens.

plurals
  1. POCOM - Implementing DllGetClassObject
    primarykey
    data
    text
    <p>I am attempting to understand creating/using COM components without the help of MFC/ATL to know its inner workings. I am using <a href="http://www.codeguru.com/cpp/com-tech/activex/tutorials/article.php/c5567/Step-by-Step-COM-Tutorial.htm%20this%20article" rel="nofollow">this codeguru article</a> for reference.Following are the steps followed by me.</p> <ul> <li>Created a Wind32 Dll,</li> <li>Added a MIDL file and declared the interface <code>IAdd</code> and library name <code>DemoMath</code>; compiled the code using MIDL compiler.</li> <li>Created <code>CAddObj</code> class deriving <code>IAdd</code> interface,provided implementation for <code>IAdd</code> and <code>IUnknown</code> interfaces.</li> <li>Created class <code>CAddFactory</code> deriving from <code>IClassFactory</code> interface;provided implementation for <code>IClassFactory</code> methods.</li> </ul> <p>Now creating <code>DllGetClassObject</code> to give client an option to invoke this function to get an instance of the class factory.</p> <p>Following is the code:</p> <pre><code>#include "stdafx.h" #include &lt;objbase.h&gt; #include "AddObjFactory.h" #include "IAdd_i.c" STDAPI DllGetClassObject(const CLSID&amp; clsid, const IID&amp; iid, void** ppv) { // //Check if the requested COM object is implemented in this DLL //There can be more than 1 COM object implemented in a DLL // if (clsid == CLSID_AddObject) { // //iid specifies the requested interface for the factory object //The client can request for IUnknown, IClassFactory, //IClassFactory2 // CAddFactory *pAddFact = new CAddFactory; if (pAddFact == NULL) return E_OUTOFMEMORY; else { return pAddFact-&gt;QueryInterface(iid , ppv); } } // //if control reaches here then that implies that the object //specified by the user is not implemented in this DLL // return CLASS_E_CLASSNOTAVAILABLE; } </code></pre> <p>Now where is <code>CLSID_AddObject</code> constant suppose to be defined or Is it generated while compiling MIDL file(I didn't find it though)?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload