|
|
1.1 ! root 1: /*** ! 2: *cfpoly.cpp - The CPoly Class Factory. ! 3: * ! 4: * Copyright (C) 1992, Microsoft Corporation. All Rights Reserved. ! 5: * Information Contained Herein Is Proprietary and Confidential. ! 6: * ! 7: *Purpose: ! 8: * This module implements the CPoly class factory. ! 9: * ! 10: *Implementation Notes: ! 11: * ! 12: *****************************************************************************/ ! 13: ! 14: #include <windows.h> ! 15: #include <ole2.h> ! 16: #include <dispatch.h> ! 17: ! 18: #include "spoly.h" ! 19: #include "cpoint.h" ! 20: #include "cpoly.h" ! 21: ! 22: ! 23: CPolyCF::CPolyCF() ! 24: { ! 25: m_refs = 0; ! 26: } ! 27: ! 28: ! 29: CPolyCF::~CPolyCF() ! 30: { ! 31: } ! 32: ! 33: ! 34: IClassFactory FAR* ! 35: CPolyCF::Create() ! 36: { ! 37: CPolyCF FAR* pCF; ! 38: ! 39: if((pCF = new FAR CPolyCF()) == NULL) ! 40: return NULL; ! 41: pCF->AddRef(); ! 42: return pCF; ! 43: } ! 44: ! 45: ! 46: //--------------------------------------------------------------------- ! 47: // IUnknown Methods ! 48: //--------------------------------------------------------------------- ! 49: ! 50: ! 51: STDMETHODIMP ! 52: CPolyCF::QueryInterface(REFIID iid, void FAR* FAR* ppv) ! 53: { ! 54: if(iid == IID_IUnknown || iid == IID_IClassFactory){ ! 55: *ppv = this; ! 56: ++m_refs; ! 57: return NOERROR; ! 58: } ! 59: *ppv = NULL; ! 60: return ResultFromScode(E_NOINTERFACE); ! 61: } ! 62: ! 63: ! 64: STDMETHODIMP_(ULONG) ! 65: CPolyCF::AddRef(void) ! 66: { ! 67: return ++m_refs; ! 68: } ! 69: ! 70: ! 71: STDMETHODIMP_(ULONG) ! 72: CPolyCF::Release(void) ! 73: { ! 74: if(--m_refs == 0){ ! 75: delete this; ! 76: return 0; ! 77: } ! 78: return m_refs; ! 79: } ! 80: ! 81: ! 82: //--------------------------------------------------------------------- ! 83: // IClassFactory Methods ! 84: //--------------------------------------------------------------------- ! 85: ! 86: ! 87: STDMETHODIMP ! 88: CPolyCF::CreateInstance( ! 89: IUnknown FAR* pUnkOuter, ! 90: REFIID iid, ! 91: void FAR* FAR* ppv) ! 92: { ! 93: HRESULT hresult; ! 94: CPoly FAR *ppoly; ! 95: ! 96: if((ppoly = CPoly::Create()) == NULL){ ! 97: *ppv = NULL; ! 98: return ResultFromScode(E_OUTOFMEMORY); ! 99: } ! 100: hresult = ppoly->QueryInterface(iid, ppv); ! 101: ppoly->Release(); ! 102: return hresult; ! 103: } ! 104: ! 105: ! 106: STDMETHODIMP ! 107: CPolyCF::LockServer(BOOL fLock) ! 108: { ! 109: return NOERROR; ! 110: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.