ReactOS 0.4.15-dev-7887-g64a59a1
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
32}
33
34//
35// destructor
36//
38{
39 VFDTRACE(0, ("CVfdFactory::~CVfdFactory()\n"));
40
42}
43
44//
45// IUnknown methods
46//
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,
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) {
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"));
125 return NOERROR;
126}
#define STDMETHODIMP
Definition: basetyps.h:43
#define STDMETHODIMP_(t)
Definition: basetyps.h:44
const GUID IID_IUnknown
const GUID IID_IClassFactory
ULONG m_cRefCnt
Definition: vfdshcfact.h:21
STDMETHODIMP QueryInterface(REFIID, LPVOID *)
Definition: vfdshcfact.cpp:47
STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID *)
Definition: vfdshcfact.cpp:92
STDMETHODIMP LockServer(BOOL)
Definition: vfdshcfact.cpp:121
STDMETHODIMP QueryInterface(REFIID, LPVOID *)
Definition: vfdshext.cpp:55
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
unsigned int BOOL
Definition: ntddk_ex.h:94
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
IClassFactory * LPCLASSFACTORY
Definition: unknwn.idl:70
ULONG AddRef()
ULONG Release()
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
uint32_t ULONG
Definition: typedefs.h:59
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
UINT g_cDllRefCnt
#define E_NOINTERFACE
Definition: winerror.h:2364
#define NOERROR
Definition: winerror.h:2354
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662