1
// ClsFact.h --- CClassFactory implementation
3
// Copyright (C) 2004, 2007 Raymond Penners <raymond@dotsphinx.com>
4
// All rights reserved.
6
// This program is free software: you can redistribute it and/or modify
7
// it under the terms of the GNU General Public License as published by
8
// the Free Software Foundation, either version 3 of the License, or
9
// (at your option) any later version.
11
// This program is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
// GNU General Public License for more details.
16
// You should have received a copy of the GNU General Public License
17
// along with this program. If not, see <http://www.gnu.org/licenses/>.
25
CClassFactory::CClassFactory(CLSID clsid)
27
TRACE_ENTER("CClassFactory::CClassFactory");
28
m_clsidObject = clsid;
35
CClassFactory::~CClassFactory()
37
TRACE_ENTER("CClassFactory::CClassFactory");
39
TRACE_MSG(g_DllRefCount);
44
STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppReturn)
48
if (IsEqualIID(riid, IID_IUnknown))
53
else if (IsEqualIID(riid, IID_IClassFactory))
55
*ppReturn = (IClassFactory*)this;
60
(*(LPUNKNOWN*)ppReturn)->AddRef();
68
STDMETHODIMP_(DWORD) CClassFactory::AddRef()
70
return ++m_ObjRefCount;
74
STDMETHODIMP_(DWORD) CClassFactory::Release()
76
if (--m_ObjRefCount == 0)
86
STDMETHODIMP CClassFactory::CreateInstance(LPUNKNOWN pUnknown,
90
HRESULT hResult = E_FAIL;
96
return CLASS_E_NOAGGREGATION;
98
//create the proper object
99
if (IsEqualCLSID(m_clsidObject, CLSID_WorkraveDeskBand))
105
CDeskBand *pDeskBand = new CDeskBand();
106
if (NULL == pDeskBand)
107
return E_OUTOFMEMORY;
114
//get the QueryInterface return for our return value
115
hResult = ((LPUNKNOWN)pTemp)->QueryInterface(riid, ppObject);
117
//call Release to decement the ref count
118
((LPUNKNOWN)pTemp)->Release();
125
STDMETHODIMP CClassFactory::LockServer(BOOL)