blob: 973dbb0aec9914583e61c88e09aac535deaba937 (
plain)
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
64
65
66
67
68
69
70
71
72
|
#include "stdafx.h"
#include "shlcom.h"
/////////////////////////////////////////////////////////////////////////////////////////
TClassFactoryRec::TClassFactoryRec() :
RefCount(0)
{
DllFactoryCount++;
}
HRESULT TClassFactoryRec::QueryInterface(REFIID riid, void **ppvObject)
{
if (riid == IID_IUnknown)
logA("TClassFactoryRec retrieved as IUnknown: %d\n", RefCount);
else if (riid == IID_IClassFactory)
logA("TClassFactoryRec retrieved as IClassFactory: %d\n", RefCount);
else {
#ifdef LOG_ENABLED
RPC_CSTR szGuid;
UuidToStringA(&riid, &szGuid);
logA("TClassFactoryRec::QueryInterface {%s} failed\n", szGuid);
RpcStringFreeA(&szGuid);
#endif
*ppvObject = NULL;
return E_NOINTERFACE;
}
AddRef();
*ppvObject = this;
return S_OK;
}
ULONG TClassFactoryRec::AddRef()
{
return ++RefCount;
}
ULONG TClassFactoryRec::Release()
{
ULONG result = --RefCount;
if (result == 0) {
logA("TClassFactoryRec released\n");
delete this;
DllFactoryCount--;
}
return result;
}
HRESULT TClassFactoryRec::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
{
if (ppvObject == 0)
return E_POINTER;
*ppvObject = NULL;
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
TShellExt *p = new TShellExt();
if (p == NULL)
return E_OUTOFMEMORY;
HRESULT hr = p->QueryInterface(riid, ppvObject);
if ( FAILED(hr))
delete p;
return hr;
}
HRESULT TClassFactoryRec::LockServer(BOOL)
{
return E_NOTIMPL;
}
|