ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

classfactory.c
Go to the documentation of this file.
00001 #include "precomp.h"
00002 
00003 typedef struct
00004 {
00005     const IClassFactoryVtbl    *lpVtbl;
00006     LONG                       ref;
00007     CLSID                      *rclsid;
00008     LPFNCREATEINSTANCE         lpfnCI;
00009     const IID *                riidInst;
00010 } IClassFactoryImpl;
00011 
00012 
00013 static
00014 HRESULT
00015 WINAPI
00016 IClassFactory_fnQueryInterface(
00017     LPCLASSFACTORY iface,
00018     REFIID riid,
00019     LPVOID *ppvObj)
00020 {
00021     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00022 
00023     *ppvObj = NULL;
00024     if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
00025     {
00026         *ppvObj = This;
00027         InterlockedIncrement(&This->ref);
00028         return S_OK;
00029     }
00030     return E_NOINTERFACE;
00031 }
00032 
00033 static
00034 ULONG
00035 WINAPI
00036 IClassFactory_fnAddRef(
00037     LPCLASSFACTORY iface)
00038 {
00039     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00040     ULONG refCount = InterlockedIncrement(&This->ref);
00041 
00042     return refCount;
00043 }
00044 
00045 static
00046 ULONG
00047 WINAPI
00048 IClassFactory_fnRelease(
00049     LPCLASSFACTORY iface)
00050 {
00051     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00052     ULONG refCount = InterlockedDecrement(&This->ref);
00053 
00054     if (!refCount)
00055     {
00056         CoTaskMemFree(This);
00057         return 0;
00058     }
00059     return refCount;
00060 }
00061 
00062 static
00063 HRESULT
00064 WINAPI
00065 IClassFactory_fnCreateInstance(
00066     LPCLASSFACTORY iface,
00067     LPUNKNOWN pUnkOuter,
00068     REFIID riid,
00069     LPVOID *ppvObject)
00070 {
00071     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00072 
00073     *ppvObject = NULL;
00074 
00075     if ( This->riidInst==NULL || IsEqualCLSID(riid, This->riidInst) || IsEqualCLSID(riid, &IID_IUnknown) )
00076     {
00077         return This->lpfnCI(pUnkOuter, riid, ppvObject);
00078     }
00079 
00080     return E_NOINTERFACE;
00081 }
00082 
00083 static
00084 HRESULT
00085 WINAPI IClassFactory_fnLockServer(
00086     LPCLASSFACTORY iface,
00087     BOOL fLock)
00088 {
00089     //IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00090     return E_NOTIMPL;
00091 }
00092 
00093 
00094 static const IClassFactoryVtbl dclfvt =
00095 {
00096     IClassFactory_fnQueryInterface,
00097     IClassFactory_fnAddRef,
00098     IClassFactory_fnRelease,
00099     IClassFactory_fnCreateInstance,
00100     IClassFactory_fnLockServer
00101 };
00102 
00103 
00104 IClassFactory * 
00105 IClassFactory_fnConstructor(
00106     LPFNCREATEINSTANCE lpfnCI, 
00107     PLONG pcRefDll, 
00108     REFIID riidInst)
00109 {
00110     IClassFactoryImpl* lpclf;
00111 
00112     lpclf = CoTaskMemAlloc(sizeof(IClassFactoryImpl));
00113     lpclf->ref = 1;
00114     lpclf->lpVtbl = &dclfvt;
00115     lpclf->lpfnCI = lpfnCI;
00116 
00117     if (pcRefDll)
00118         InterlockedIncrement(pcRefDll);
00119     lpclf->riidInst = riidInst;
00120 
00121     return (LPCLASSFACTORY)lpclf;
00122 }
00123 
00124 

Generated on Sun May 27 2012 04:21:43 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.