Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

107 lines
1.7 KiB

//-----------------------------------------------------------------------------
// File: ipageclassfact.cpp
//
// Desc: Implements the class factory for the page object.
//
// Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
//-----------------------------------------------------------------------------
#include "common.hpp"
//QI
STDMETHODIMP CPageFactory::QueryInterface(REFIID riid, LPVOID* ppv)
{
//null the put parameter
*ppv = NULL;
if ((riid == IID_IUnknown) || (riid == IID_IClassFactory))
{
*ppv = this;
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
//AddRef
STDMETHODIMP_(ULONG) CPageFactory::AddRef()
{
return InterlockedIncrement(&m_cRef);
}
//Release
STDMETHODIMP_(ULONG) CPageFactory::Release()
{
if (InterlockedDecrement(&m_cRef) == 0)
{
delete this;
return 0;
}
return m_cRef;
}
//CreateInstance
STDMETHODIMP CPageFactory::CreateInstance(IUnknown* pUnkOuter, REFIID riid, LPVOID *ppv)
{
HRESULT hr = S_OK;
//can't aggregate
if (pUnkOuter != NULL)
{
return CLASS_E_NOAGGREGATION;
}
//create component
CDIDeviceActionConfigPage* pFE = new CDIDeviceActionConfigPage();
if (pFE == NULL)
{
return E_OUTOFMEMORY;
}
//get the requested interface
hr = pFE->QueryInterface(riid, ppv);
//release IUnknown
pFE->Release();
return hr;
}
//LockServer
STDMETHODIMP CPageFactory::LockServer(BOOL bLock)
{
HRESULT hr = S_OK;
if (bLock)
{
InterlockedIncrement(&g_cServerLocks);
}
else
{
InterlockedDecrement(&g_cServerLocks);
}
return hr;
}
//constructor
CPageFactory::CPageFactory()
{
m_cRef = 1;
}
//destructor
CPageFactory::~CPageFactory()
{
}