ReactOS  0.4.14-dev-323-g6fe6a88
vfdshcfact.cpp
Go to the documentation of this file.
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 //
26 {
27  VFDTRACE(0, ("CVfdFactory::CVfdFactory()\n"));
28 
29  m_cRefCnt = 0L;
30 
31  g_cDllRefCnt++;
32 }
33 
34 //
35 // destructor
36 //
38 {
39  VFDTRACE(0, ("CVfdFactory::~CVfdFactory()\n"));
40 
41  g_cDllRefCnt--;
42 }
43 
44 //
45 // IUnknown methods
46 //
48  REFIID riid,
49  LPVOID *ppv)
50 {
51  VFDTRACE(0, ("CVfdFactory::QueryInterface()\n"));
52 
53  *ppv = NULL;
54 
57  *ppv = (LPCLASSFACTORY)this;
58 
59  AddRef();
60 
61  return NOERROR;
62  }
63 
64  return E_NOINTERFACE;
65 }
66 
68 {
69  VFDTRACE(0, ("CVfdFactory::AddRef()\n"));
70 
71  return ++m_cRefCnt;
72 }
73 
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 //
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 
122 {
123  VFDTRACE(0, ("CVfdFactory::LockServer()\n"));
124  UNREFERENCED_PARAMETER(fLock);
125  return NOERROR;
126 }
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
UINT g_cDllRefCnt
#define NOERROR
Definition: winerror.h:2354
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
STDMETHODIMP_(ULONG) CVfdFactory
Definition: vfdshcfact.cpp:67
ULONG m_cRefCnt
Definition: vfdshcfact.h:21
STDMETHODIMP QueryInterface(REFIID, LPVOID *)
Definition: vfdshext.cpp:55
STDMETHODIMP QueryInterface(REFIID, LPVOID *)
Definition: vfdshcfact.cpp:47
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
#define STDMETHODIMP
Definition: basetyps.h:43
ULONG Release()
smooth NULL
Definition: ftsmooth.c:416
const GUID IID_IUnknown
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
ULONG AddRef()
static const WCHAR L[]
Definition: oid.c:1250
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID *)
Definition: vfdshcfact.cpp:92
STDMETHODIMP LockServer(BOOL)
Definition: vfdshcfact.cpp:121
unsigned int ULONG
Definition: retypes.h:1
const GUID IID_IClassFactory
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
IClassFactory * LPCLASSFACTORY
Definition: unknwn.idl:70