blob: 7da337d517d3f93087631cdef0906fac6ea3e46e (
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
//
// Copyright (C) Microsoft Corporation 2005
// IHV UI Extension sample
//
#include "precomp.h"
#include "ihvuiinc_i.c"
extern long g_serverLock; //lock count on server
//
// IUnknown Implementation
//
CIHVClassFactory::CIHVClassFactory() : m_refCount(1)
{
}
CIHVClassFactory::~CIHVClassFactory()
{
}
STDMETHODIMP_(ULONG)
CIHVClassFactory::AddRef()
{
return InterlockedIncrement(&m_refCount);
}
STDMETHODIMP_(ULONG)
CIHVClassFactory::Release()
{
ULONG refCount = InterlockedDecrement(&m_refCount);
if (refCount == 0)
{
delete this;
}
return refCount;
}
STDMETHODIMP
CIHVClassFactory::QueryInterface(
REFIID riid,
void **ppvObject
)
{
HRESULT hr = E_INVALIDARG;
if (NULL != ppvObject)
{
hr = S_OK;
if (riid == IID_IUnknown)
{
*ppvObject = static_cast<IUnknown *>(this);
}
else if (riid == IID_IClassFactory)
{
*ppvObject = static_cast<IClassFactory *>(this);
}
else
{
*ppvObject = NULL;
return E_NOINTERFACE;
}
reinterpret_cast<IUnknown *>(*ppvObject)->AddRef();
}
return hr;
}
//
// IClassFactory Implementaion
//
STDMETHODIMP
CIHVClassFactory::CreateInstance(
IUnknown *pUnkOuter,
REFIID riid,
void **ppvObject
)
{
HRESULT hr = E_NOINTERFACE;
// aggregation not supported
if (pUnkOuter != NULL)
{
return CLASS_E_NOAGGREGATION;
}
if (NULL == ppvObject)
{
return E_INVALIDARG;
}
// Figure out which interface is wanted
// the ui will call us only as IID_IDot11ExtUI
if (IID_IDot11SampleExtUI == riid ||
IID_IDot11ExtUI == riid ||
IID_IWizardExtension == riid)
{
CDot11SampleExtUI *pExtUI = new(std::nothrow) CDot11SampleExtUI();
if (NULL == pExtUI)
{
return E_OUTOFMEMORY;
}
pExtUI->AddRef();
hr = pExtUI->QueryInterface(riid, ppvObject);
pExtUI->Release();
}
else if (IID_IDot11SampleExtUIConProperty == riid)
{
CDot11SampleExtUIConProperty *pCDot11SampleExtUIConProperty = new(std::nothrow) CDot11SampleExtUIConProperty();
if (NULL == pCDot11SampleExtUIConProperty)
{
return E_OUTOFMEMORY;
}
pCDot11SampleExtUIConProperty->AddRef();
hr = pCDot11SampleExtUIConProperty->QueryInterface(riid, ppvObject);
pCDot11SampleExtUIConProperty->Release();
}
else if (IID_IDot11SampleExtUISecProperty == riid)
{
CDot11SampleExtUISecProperty *pCDot11SampleExtUISecProperty = new(std::nothrow) CDot11SampleExtUISecProperty();
if (NULL == pCDot11SampleExtUISecProperty)
{
return E_OUTOFMEMORY;
}
pCDot11SampleExtUISecProperty->AddRef();
hr = pCDot11SampleExtUISecProperty->QueryInterface(riid, ppvObject);
pCDot11SampleExtUISecProperty->Release();
}
else if (IID_IDot11SampleExtUIKeyProperty == riid)
{
CDot11SampleExtUIKeyProperty *pCDot11SampleExtUIKeyProperty = new(std::nothrow) CDot11SampleExtUIKeyProperty();
if (NULL == pCDot11SampleExtUIKeyProperty)
{
return E_OUTOFMEMORY;
}
pCDot11SampleExtUIKeyProperty->AddRef();
hr = pCDot11SampleExtUIKeyProperty->QueryInterface(riid, ppvObject);
pCDot11SampleExtUIKeyProperty->Release();
}
return hr;
}
STDMETHODIMP
CIHVClassFactory::LockServer(BOOL fLock)
{
if (fLock)
{
InterlockedIncrement(&g_serverLock);
}
else
{
InterlockedDecrement(&g_serverLock);
}
return S_OK;
}
|