Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenclassfactory.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS Configuration of network devices 00004 * FILE: dll/directx/dsound_new/classfactory.c 00005 * PURPOSE: IClassFactory implementation 00006 * 00007 * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) 00008 */ 00009 00010 00011 #include "precomp.h" 00012 00013 typedef struct 00014 { 00015 const IClassFactoryVtbl *lpVtbl; 00016 LONG ref; 00017 CLSID *rclsid; 00018 LPFNCREATEINSTANCE lpfnCI; 00019 const IID * riidInst; 00020 } IClassFactoryImpl; 00021 00022 00023 static 00024 HRESULT 00025 WINAPI 00026 IClassFactory_fnQueryInterface( 00027 LPCLASSFACTORY iface, 00028 REFIID riid, 00029 LPVOID *ppvObj) 00030 { 00031 IClassFactoryImpl *This = (IClassFactoryImpl *)iface; 00032 00033 *ppvObj = NULL; 00034 00035 /* check requested interface */ 00036 if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory)) 00037 { 00038 *ppvObj = This; 00039 InterlockedIncrement(&This->ref); 00040 return S_OK; 00041 } 00042 return E_NOINTERFACE; 00043 } 00044 00045 static 00046 ULONG 00047 WINAPI 00048 IClassFactory_fnAddRef( 00049 LPCLASSFACTORY iface) 00050 { 00051 IClassFactoryImpl *This = (IClassFactoryImpl *)iface; 00052 00053 /* increment reference count */ 00054 ULONG refCount = InterlockedIncrement(&This->ref); 00055 00056 return refCount; 00057 } 00058 00059 static 00060 ULONG 00061 WINAPI 00062 IClassFactory_fnRelease( 00063 LPCLASSFACTORY iface) 00064 { 00065 IClassFactoryImpl *This = (IClassFactoryImpl *)iface; 00066 ULONG refCount = InterlockedDecrement(&This->ref); 00067 00068 /* decrement reference count */ 00069 if (!refCount) 00070 { 00071 /* free class factory */ 00072 CoTaskMemFree(This); 00073 return 0; 00074 } 00075 return refCount; 00076 } 00077 00078 static 00079 HRESULT 00080 WINAPI 00081 IClassFactory_fnCreateInstance( 00082 LPCLASSFACTORY iface, 00083 LPUNKNOWN pUnkOuter, 00084 REFIID riid, 00085 LPVOID *ppvObject) 00086 { 00087 IClassFactoryImpl *This = (IClassFactoryImpl *)iface; 00088 00089 if (!ppvObject) 00090 return E_INVALIDARG; 00091 00092 *ppvObject = NULL; 00093 00094 if ( This->riidInst==NULL || IsEqualCLSID(riid, This->riidInst) || IsEqualCLSID(riid, &IID_IUnknown) ) 00095 { 00096 /* instantiate object */ 00097 return This->lpfnCI(pUnkOuter, riid, ppvObject); 00098 } 00099 00100 return E_NOINTERFACE; 00101 } 00102 00103 static 00104 HRESULT 00105 WINAPI IClassFactory_fnLockServer( 00106 LPCLASSFACTORY iface, 00107 BOOL fLock) 00108 { 00109 //IClassFactoryImpl *This = (IClassFactoryImpl *)iface; 00110 return E_NOTIMPL; 00111 } 00112 00113 00114 static const IClassFactoryVtbl dclfvt = 00115 { 00116 IClassFactory_fnQueryInterface, 00117 IClassFactory_fnAddRef, 00118 IClassFactory_fnRelease, 00119 IClassFactory_fnCreateInstance, 00120 IClassFactory_fnLockServer 00121 }; 00122 00123 00124 IClassFactory * 00125 IClassFactory_fnConstructor( 00126 LPFNCREATEINSTANCE lpfnCI, 00127 PLONG pcRefDll, 00128 REFIID riidInst) 00129 { 00130 IClassFactoryImpl* lpclf; 00131 00132 lpclf = CoTaskMemAlloc(sizeof(IClassFactoryImpl)); 00133 lpclf->ref = 1; 00134 lpclf->lpVtbl = &dclfvt; 00135 lpclf->lpfnCI = lpfnCI; 00136 00137 if (pcRefDll) 00138 InterlockedIncrement(pcRefDll); 00139 lpclf->riidInst = riidInst; 00140 00141 return (LPCLASSFACTORY)lpclf; 00142 } 00143 00144 Generated on Fri May 25 2012 04:19:37 for ReactOS by
1.7.6.1
|