called by COM to get the class factory object for a given class
| 174 | |
| 175 | //called by COM to get the class factory object for a given class |
| 176 | STDAPI DllGetClassObject(REFCLSID rClsID,REFIID riid,void **pv) |
| 177 | { |
| 178 | // DebugBreak(); |
| 179 | |
| 180 | if (!(riid == IID_IUnknown) && !(riid == IID_IClassFactory)) { |
| 181 | return E_NOINTERFACE; |
| 182 | } |
| 183 | |
| 184 | // traverse the array of templates looking for one with this |
| 185 | // class id |
| 186 | for (int i = 0; i < g_cTemplates; i++) { |
| 187 | const CFactoryTemplate * pT = &g_Templates[i]; |
| 188 | if (pT->IsClassID(rClsID)) { |
| 189 | |
| 190 | // found a template - make a class factory based on this |
| 191 | // template |
| 192 | |
| 193 | *pv = (LPVOID) (LPUNKNOWN) new CClassFactory(pT); |
| 194 | if (*pv == NULL) { |
| 195 | return E_OUTOFMEMORY; |
| 196 | } |
| 197 | ((LPUNKNOWN)*pv)->AddRef(); |
| 198 | return NOERROR; |
| 199 | } |
| 200 | } |
| 201 | return CLASS_E_CLASSNOTAVAILABLE; |
| 202 | } |
| 203 | |
| 204 | // |
| 205 | // Call any initialization routines |