/***************************************************************************** * com.c : our implementation of COM * REALmagic Quasar Hardware Library * Created by Michael Ignaszewski * Copyright Sigma Designs Inc * Sigma Designs Proprietary and confidential * Created on 8/27/99 * Description: *****************************************************************************/ #include "pch.h" #include "template.h" // General Module Definitions int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]); //called by COM to get the class factory object for a given class HRESULT ModCreateInstance(DWORD dwInstance, QIID* rclsid, QIID* riid, LPVOID * ppv) { int i = 0; // traverse the array of templates looking for one with this // class id for (i = 0; i < g_cTemplates; i++) { CSDFactoryTemplate * pT = &g_Templates[i]; if (pT->m_QIID == (QIID*)rclsid) { // found a template - make a class factory based on this // template if (pT->m_lpfnNew != NULL) pT->m_lpfnNew (ppv, dwInstance); else return CLASS_E_CLASSNOTAVAILABLE; if (*ppv == NULL) { return E_OUTOFMEMORY; } return NOERROR; } } return CLASS_E_CLASSNOTAVAILABLE; }