Reactos
at master 126 lines 2.0 kB view raw
1/* 2 vfdshcfact.cpp 3 4 Virtual Floppy Drive for Windows 5 Driver control library 6 shell extension COM class factory class 7 8 Copyright (c) 2003-2005 Ken Kato 9*/ 10 11#define WIN32_LEAN_AND_MEAN 12#include <windows.h> 13#include <shlobj.h> 14 15#include "vfdtypes.h" 16#include "vfdlib.h" 17#include "vfdshext.h" 18 19// class header 20#include "vfdshcfact.h" 21 22// 23// constructor 24// 25CVfdFactory::CVfdFactory() 26{ 27 VFDTRACE(0, ("CVfdFactory::CVfdFactory()\n")); 28 29 m_cRefCnt = 0L; 30 31 g_cDllRefCnt++; 32} 33 34// 35// destructor 36// 37CVfdFactory::~CVfdFactory() 38{ 39 VFDTRACE(0, ("CVfdFactory::~CVfdFactory()\n")); 40 41 g_cDllRefCnt--; 42} 43 44// 45// IUnknown methods 46// 47STDMETHODIMP CVfdFactory::QueryInterface( 48 REFIID riid, 49 LPVOID *ppv) 50{ 51 VFDTRACE(0, ("CVfdFactory::QueryInterface()\n")); 52 53 *ppv = NULL; 54 55 if (IsEqualIID(riid, IID_IUnknown) || 56 IsEqualIID(riid, IID_IClassFactory)) { 57 *ppv = (LPCLASSFACTORY)this; 58 59 AddRef(); 60 61 return NOERROR; 62 } 63 64 return E_NOINTERFACE; 65} 66 67STDMETHODIMP_(ULONG) CVfdFactory::AddRef() 68{ 69 VFDTRACE(0, ("CVfdFactory::AddRef()\n")); 70 71 return ++m_cRefCnt; 72} 73 74STDMETHODIMP_(ULONG) CVfdFactory::Release() 75{ 76 VFDTRACE(0, ("CVfdFactory::Release()\n")); 77 78 if (--m_cRefCnt) { 79 return m_cRefCnt; 80 } 81 82#ifndef __REACTOS__ 83 delete this; 84#endif 85 86 return 0L; 87} 88 89// 90// IClassFactory methods 91// 92STDMETHODIMP CVfdFactory::CreateInstance( 93 LPUNKNOWN pUnkOuter, 94 REFIID riid, 95 LPVOID *ppvObj) 96{ 97 VFDTRACE(0, ("CVfdFactory::CreateInstance()\n")); 98 99 *ppvObj = NULL; 100 101 // Shell extensions typically don't support 102 // aggregation (inheritance) 103 104 if (pUnkOuter) { 105 return CLASS_E_NOAGGREGATION; 106 } 107 108 // Create the main shell extension object. 109 // The shell will then call QueryInterface with IID_IShellExtInit 110 // -- this is how shell extensions are initialized. 111 112 LPCVFDSHEXT pVfdShExt = new CVfdShExt; 113 114 if (!pVfdShExt) { 115 return E_OUTOFMEMORY; 116 } 117 118 return pVfdShExt->QueryInterface(riid, ppvObj); 119} 120 121STDMETHODIMP CVfdFactory::LockServer(BOOL fLock) 122{ 123 VFDTRACE(0, ("CVfdFactory::LockServer()\n")); 124 UNREFERENCED_PARAMETER(fLock); 125 return NOERROR; 126}