diff options
| author | karlf <[email protected]> | 2016-08-11 13:28:13 -0700 |
|---|---|---|
| committer | karlf <[email protected]> | 2016-08-11 13:28:13 -0700 |
| commit | 96eb96dfb613e4c745db6bd1f53a92fe7e2290fc (patch) | |
| tree | ad5f3ede5cbcd6b598677ce41bcf8318471bdd92 /network/wlan/ihvsampleui/IHVClassFactory.cpp | |
| parent | 687b274aa38fd05c8c26e3068932121876d7f745 (diff) | |
Updated for "Windows 10 Anniversary Update" (Version 1607)
Diffstat (limited to 'network/wlan/ihvsampleui/IHVClassFactory.cpp')
| -rw-r--r-- | network/wlan/ihvsampleui/IHVClassFactory.cpp | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/network/wlan/ihvsampleui/IHVClassFactory.cpp b/network/wlan/ihvsampleui/IHVClassFactory.cpp new file mode 100644 index 00000000..7da337d5 --- /dev/null +++ b/network/wlan/ihvsampleui/IHVClassFactory.cpp @@ -0,0 +1,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; +} |
