-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCResourceManagerFactory.cpp
63 lines (50 loc) · 1.23 KB
/
CResourceManagerFactory.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "stdafx.h"
#include "CResourceManagerFactory.h"
#include "CResourceManager.h"
ULONG CResourceManagerFactory::AddRef()
{
return ++m_cRef;
}
ULONG CResourceManagerFactory::Release()
{
if(--m_cRef != 0)
return m_cRef;
delete this;
return 0;
}
HRESULT CResourceManagerFactory::QueryInterface(REFIID riid, void** ppv)
{
if(riid == IID_IUnknown)
*ppv = (IUnknown*)this;
else if(riid == IID_IClassFactory)
*ppv = (IClassFactory*)this;
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
AddRef();
return S_OK;
}
HRESULT CResourceManagerFactory::CreateInstance(IUnknown *pUnknownOuter,
REFIID riid, void** ppv)
{
if(pUnknownOuter != NULL)
return CLASS_E_NOAGGREGATION;
// Initialize returned object pointer to NULL
*ppv = NULL;
CResourceManager *pResManager = new CResourceManager(NULL);
if(pResManager == NULL)
return E_OUTOFMEMORY;
HRESULT hr = pResManager->QueryInterface(riid, ppv);
pResManager->Release();
return hr;
}
HRESULT CResourceManagerFactory::LockServer(BOOL bLock)
{
if(bLock)
g_cLocks++;
else
g_cLocks--;
return S_OK;
}