-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathIUnknownObj.cpp
More file actions
39 lines (35 loc) · 852 Bytes
/
IUnknownObj.cpp
File metadata and controls
39 lines (35 loc) · 852 Bytes
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
#include "IUnknownObj.h"
IUnknownObj::IUnknownObj() {
m_cRef = 1;
return;
}
///////////////////////IUknown Interface
HRESULT IUnknownObj::QueryInterface(const IID& riid, void** ppvObj) {
// Always set out parameter to NULL, validating it first.
if (!ppvObj) {
//printf("QueryInterface INVALID\n");
return E_INVALIDARG;
}
if (riid == IID_IUnknown)
{
*ppvObj = static_cast<IUnknownObj*>(this);
reinterpret_cast<IUnknown*>(*ppvObj)->AddRef();
}
else
{
*ppvObj = NULL;
//printf("QueryInterface NOINT\n");
return E_NOINTERFACE;
}
// Increment the reference count and return the pointer.
return S_OK;
}
ULONG IUnknownObj::AddRef() {
m_cRef++;
return m_cRef;
}
ULONG IUnknownObj::Release() {
// Decrement the object's internal counter.
ULONG ulRefCount = m_cRef--;
return ulRefCount;
}