xref: /reactos/dll/shellext/deskmon/shxiface.c (revision c2c66aff)
1*c2c66affSColin Finck #include "precomp.h"
2*c2c66affSColin Finck 
3*c2c66affSColin Finck #define NDEBUG
4*c2c66affSColin Finck #include <debug.h>
5*c2c66affSColin Finck 
6*c2c66affSColin Finck LONG dll_refs = 0;
7*c2c66affSColin Finck 
8*c2c66affSColin Finck static HRESULT STDMETHODCALLTYPE
IDeskMonitor_IShellPropSheetExt_QueryInterface(IShellPropSheetExt * iface,REFIID iid,PVOID * pvObject)9*c2c66affSColin Finck IDeskMonitor_IShellPropSheetExt_QueryInterface(IShellPropSheetExt *iface,
10*c2c66affSColin Finck                                                REFIID iid,
11*c2c66affSColin Finck                                                PVOID *pvObject)
12*c2c66affSColin Finck {
13*c2c66affSColin Finck     PDESKMONITOR This = interface_to_impl(iface, IShellPropSheetExt);
14*c2c66affSColin Finck     return IDeskMonitor_QueryInterface(This,
15*c2c66affSColin Finck                                        iid,
16*c2c66affSColin Finck                                        pvObject);
17*c2c66affSColin Finck }
18*c2c66affSColin Finck 
19*c2c66affSColin Finck static ULONG STDMETHODCALLTYPE
IDeskMonitor_IShellPropSheetExt_AddRef(IShellPropSheetExt * iface)20*c2c66affSColin Finck IDeskMonitor_IShellPropSheetExt_AddRef(IShellPropSheetExt* iface)
21*c2c66affSColin Finck {
22*c2c66affSColin Finck     PDESKMONITOR This = interface_to_impl(iface, IShellPropSheetExt);
23*c2c66affSColin Finck     return IDeskMonitor_AddRef(This);
24*c2c66affSColin Finck }
25*c2c66affSColin Finck 
26*c2c66affSColin Finck static ULONG STDMETHODCALLTYPE
IDeskMonitor_IShellPropSheetExt_Release(IShellPropSheetExt * iface)27*c2c66affSColin Finck IDeskMonitor_IShellPropSheetExt_Release(IShellPropSheetExt* iface)
28*c2c66affSColin Finck {
29*c2c66affSColin Finck     PDESKMONITOR This = interface_to_impl(iface, IShellPropSheetExt);
30*c2c66affSColin Finck     return IDeskMonitor_Release(This);
31*c2c66affSColin Finck }
32*c2c66affSColin Finck 
33*c2c66affSColin Finck static HRESULT STDMETHODCALLTYPE
IDeskMonitor_IShellPropSheetExt_AddPages(IShellPropSheetExt * iface,LPFNADDPROPSHEETPAGE pfnAddPage,LPARAM lParam)34*c2c66affSColin Finck IDeskMonitor_IShellPropSheetExt_AddPages(IShellPropSheetExt* iface,
35*c2c66affSColin Finck                                          LPFNADDPROPSHEETPAGE pfnAddPage,
36*c2c66affSColin Finck                                          LPARAM lParam)
37*c2c66affSColin Finck {
38*c2c66affSColin Finck     PDESKMONITOR This = interface_to_impl(iface, IShellPropSheetExt);
39*c2c66affSColin Finck     return IDeskMonitor_AddPages(This,
40*c2c66affSColin Finck                                  pfnAddPage,
41*c2c66affSColin Finck                                  lParam);
42*c2c66affSColin Finck }
43*c2c66affSColin Finck 
44*c2c66affSColin Finck static HRESULT STDMETHODCALLTYPE
IDeskMonitor_IShellPropSheetExt_ReplacePage(IShellPropSheetExt * iface,EXPPS uPageID,LPFNADDPROPSHEETPAGE pfnReplacePage,LPARAM lParam)45*c2c66affSColin Finck IDeskMonitor_IShellPropSheetExt_ReplacePage(IShellPropSheetExt* iface,
46*c2c66affSColin Finck                                             EXPPS uPageID,
47*c2c66affSColin Finck                                             LPFNADDPROPSHEETPAGE pfnReplacePage,
48*c2c66affSColin Finck                                             LPARAM lParam)
49*c2c66affSColin Finck {
50*c2c66affSColin Finck     PDESKMONITOR This = interface_to_impl(iface, IShellPropSheetExt);
51*c2c66affSColin Finck     return IDeskMonitor_ReplacePage(This,
52*c2c66affSColin Finck                                     uPageID,
53*c2c66affSColin Finck                                     pfnReplacePage,
54*c2c66affSColin Finck                                     lParam);
55*c2c66affSColin Finck }
56*c2c66affSColin Finck 
57*c2c66affSColin Finck static IShellPropSheetExtVtbl efvtIShellPropSheetExt =
58*c2c66affSColin Finck {
59*c2c66affSColin Finck     IDeskMonitor_IShellPropSheetExt_QueryInterface,
60*c2c66affSColin Finck     IDeskMonitor_IShellPropSheetExt_AddRef,
61*c2c66affSColin Finck     IDeskMonitor_IShellPropSheetExt_Release,
62*c2c66affSColin Finck     IDeskMonitor_IShellPropSheetExt_AddPages,
63*c2c66affSColin Finck     IDeskMonitor_IShellPropSheetExt_ReplacePage
64*c2c66affSColin Finck };
65*c2c66affSColin Finck 
66*c2c66affSColin Finck static HRESULT STDMETHODCALLTYPE
IDeskMonitor_IShellExtInit_QueryInterface(IShellExtInit * iface,REFIID iid,PVOID * pvObject)67*c2c66affSColin Finck IDeskMonitor_IShellExtInit_QueryInterface(IShellExtInit *iface,
68*c2c66affSColin Finck                                           REFIID iid,
69*c2c66affSColin Finck                                           PVOID *pvObject)
70*c2c66affSColin Finck {
71*c2c66affSColin Finck     PDESKMONITOR This = interface_to_impl(iface, IShellExtInit);
72*c2c66affSColin Finck     return IDeskMonitor_QueryInterface(This,
73*c2c66affSColin Finck                                        iid,
74*c2c66affSColin Finck                                        pvObject);
75*c2c66affSColin Finck }
76*c2c66affSColin Finck 
77*c2c66affSColin Finck static ULONG STDMETHODCALLTYPE
IDeskMonitor_IShellExtInit_AddRef(IShellExtInit * iface)78*c2c66affSColin Finck IDeskMonitor_IShellExtInit_AddRef(IShellExtInit* iface)
79*c2c66affSColin Finck {
80*c2c66affSColin Finck     PDESKMONITOR This = interface_to_impl(iface, IShellExtInit);
81*c2c66affSColin Finck     return IDeskMonitor_AddRef(This);
82*c2c66affSColin Finck }
83*c2c66affSColin Finck 
84*c2c66affSColin Finck static ULONG STDMETHODCALLTYPE
IDeskMonitor_IShellExtInit_Release(IShellExtInit * iface)85*c2c66affSColin Finck IDeskMonitor_IShellExtInit_Release(IShellExtInit* iface)
86*c2c66affSColin Finck {
87*c2c66affSColin Finck     PDESKMONITOR This = interface_to_impl(iface, IShellExtInit);
88*c2c66affSColin Finck     return IDeskMonitor_Release(This);
89*c2c66affSColin Finck }
90*c2c66affSColin Finck 
91*c2c66affSColin Finck static HRESULT STDMETHODCALLTYPE
IDeskMonitor_IShellExtInit_Initialize(IShellExtInit * iface,LPCITEMIDLIST pidlFolder,IDataObject * pdtobj,HKEY hkeyProgID)92*c2c66affSColin Finck IDeskMonitor_IShellExtInit_Initialize(IShellExtInit* iface,
93*c2c66affSColin Finck                                       LPCITEMIDLIST pidlFolder,
94*c2c66affSColin Finck                                       IDataObject *pdtobj,
95*c2c66affSColin Finck                                       HKEY hkeyProgID)
96*c2c66affSColin Finck {
97*c2c66affSColin Finck     PDESKMONITOR This = interface_to_impl(iface, IShellExtInit);
98*c2c66affSColin Finck     return IDeskMonitor_Initialize(This,
99*c2c66affSColin Finck                                    pidlFolder,
100*c2c66affSColin Finck                                    pdtobj,
101*c2c66affSColin Finck                                    hkeyProgID);
102*c2c66affSColin Finck }
103*c2c66affSColin Finck 
104*c2c66affSColin Finck static IShellExtInitVtbl efvtIShellExtInit =
105*c2c66affSColin Finck {
106*c2c66affSColin Finck     IDeskMonitor_IShellExtInit_QueryInterface,
107*c2c66affSColin Finck     IDeskMonitor_IShellExtInit_AddRef,
108*c2c66affSColin Finck     IDeskMonitor_IShellExtInit_Release,
109*c2c66affSColin Finck     IDeskMonitor_IShellExtInit_Initialize
110*c2c66affSColin Finck };
111*c2c66affSColin Finck 
112*c2c66affSColin Finck static HRESULT STDMETHODCALLTYPE
IDeskMonitor_IClassFactory_QueryInterface(IClassFactory * iface,REFIID iid,PVOID * pvObject)113*c2c66affSColin Finck IDeskMonitor_IClassFactory_QueryInterface(IClassFactory *iface,
114*c2c66affSColin Finck                                           REFIID iid,
115*c2c66affSColin Finck                                           PVOID *pvObject)
116*c2c66affSColin Finck {
117*c2c66affSColin Finck     PDESKMONITOR This = interface_to_impl(iface, IClassFactory);
118*c2c66affSColin Finck     return IDeskMonitor_QueryInterface(This,
119*c2c66affSColin Finck                                        iid,
120*c2c66affSColin Finck                                        pvObject);
121*c2c66affSColin Finck }
122*c2c66affSColin Finck 
123*c2c66affSColin Finck static ULONG STDMETHODCALLTYPE
IDeskMonitor_IClassFactory_AddRef(IClassFactory * iface)124*c2c66affSColin Finck IDeskMonitor_IClassFactory_AddRef(IClassFactory* iface)
125*c2c66affSColin Finck {
126*c2c66affSColin Finck     PDESKMONITOR This = interface_to_impl(iface, IClassFactory);
127*c2c66affSColin Finck     return IDeskMonitor_AddRef(This);
128*c2c66affSColin Finck }
129*c2c66affSColin Finck 
130*c2c66affSColin Finck static ULONG STDMETHODCALLTYPE
IDeskMonitor_IClassFactory_Release(IClassFactory * iface)131*c2c66affSColin Finck IDeskMonitor_IClassFactory_Release(IClassFactory* iface)
132*c2c66affSColin Finck {
133*c2c66affSColin Finck     PDESKMONITOR This = interface_to_impl(iface, IClassFactory);
134*c2c66affSColin Finck     return IDeskMonitor_Release(This);
135*c2c66affSColin Finck }
136*c2c66affSColin Finck 
137*c2c66affSColin Finck static HRESULT STDMETHODCALLTYPE
IDeskMonitor_IClassFactory_CreateInstance(IClassFactory * iface,IUnknown * pUnkOuter,REFIID riid,PVOID * ppvObject)138*c2c66affSColin Finck IDeskMonitor_IClassFactory_CreateInstance(IClassFactory *iface,
139*c2c66affSColin Finck                                           IUnknown * pUnkOuter,
140*c2c66affSColin Finck                                           REFIID riid,
141*c2c66affSColin Finck                                           PVOID *ppvObject)
142*c2c66affSColin Finck {
143*c2c66affSColin Finck     if (pUnkOuter != NULL &&
144*c2c66affSColin Finck         !IsEqualIID(riid,
145*c2c66affSColin Finck                     &IID_IUnknown))
146*c2c66affSColin Finck     {
147*c2c66affSColin Finck         return CLASS_E_NOAGGREGATION;
148*c2c66affSColin Finck     }
149*c2c66affSColin Finck 
150*c2c66affSColin Finck     return IDeskMonitor_Constructor(riid,
151*c2c66affSColin Finck                                     ppvObject);
152*c2c66affSColin Finck }
153*c2c66affSColin Finck 
154*c2c66affSColin Finck static HRESULT STDMETHODCALLTYPE
IDeskMonitor_IClassFactory_LockServer(IClassFactory * iface,BOOL fLock)155*c2c66affSColin Finck IDeskMonitor_IClassFactory_LockServer(IClassFactory *iface,
156*c2c66affSColin Finck                                       BOOL fLock)
157*c2c66affSColin Finck {
158*c2c66affSColin Finck     if (fLock)
159*c2c66affSColin Finck         InterlockedIncrement(&dll_refs);
160*c2c66affSColin Finck     else
161*c2c66affSColin Finck         InterlockedDecrement(&dll_refs);
162*c2c66affSColin Finck 
163*c2c66affSColin Finck     return S_OK;
164*c2c66affSColin Finck }
165*c2c66affSColin Finck 
166*c2c66affSColin Finck static IClassFactoryVtbl efvtIClassFactory =
167*c2c66affSColin Finck {
168*c2c66affSColin Finck     IDeskMonitor_IClassFactory_QueryInterface,
169*c2c66affSColin Finck     IDeskMonitor_IClassFactory_AddRef,
170*c2c66affSColin Finck     IDeskMonitor_IClassFactory_Release,
171*c2c66affSColin Finck     IDeskMonitor_IClassFactory_CreateInstance,
172*c2c66affSColin Finck     IDeskMonitor_IClassFactory_LockServer,
173*c2c66affSColin Finck };
174*c2c66affSColin Finck 
175*c2c66affSColin Finck VOID
IDeskMonitor_InitIface(PDESKMONITOR This)176*c2c66affSColin Finck IDeskMonitor_InitIface(PDESKMONITOR This)
177*c2c66affSColin Finck {
178*c2c66affSColin Finck     This->lpIShellPropSheetExtVtbl = &efvtIShellPropSheetExt;
179*c2c66affSColin Finck     This->lpIShellExtInitVtbl = &efvtIShellExtInit;
180*c2c66affSColin Finck     This->lpIClassFactoryVtbl = &efvtIClassFactory;
181*c2c66affSColin Finck 
182*c2c66affSColin Finck     IDeskMonitor_AddRef(This);
183*c2c66affSColin Finck }
184*c2c66affSColin Finck 
185*c2c66affSColin Finck HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid,REFIID riid,LPVOID * ppv)186*c2c66affSColin Finck DllGetClassObject(REFCLSID rclsid,
187*c2c66affSColin Finck                   REFIID riid,
188*c2c66affSColin Finck                   LPVOID *ppv)
189*c2c66affSColin Finck {
190*c2c66affSColin Finck     if (ppv == NULL)
191*c2c66affSColin Finck         return E_INVALIDARG;
192*c2c66affSColin Finck 
193*c2c66affSColin Finck     *ppv = NULL;
194*c2c66affSColin Finck     if (IsEqualCLSID(rclsid,
195*c2c66affSColin Finck                      &CLSID_IDeskMonitor))
196*c2c66affSColin Finck     {
197*c2c66affSColin Finck         return IDeskMonitor_Constructor(riid,
198*c2c66affSColin Finck                                         ppv);
199*c2c66affSColin Finck     }
200*c2c66affSColin Finck 
201*c2c66affSColin Finck     DPRINT1("DllGetClassObject: CLASS_E_CLASSNOTAVAILABLE\n");
202*c2c66affSColin Finck     return CLASS_E_CLASSNOTAVAILABLE;
203*c2c66affSColin Finck }
204*c2c66affSColin Finck 
205*c2c66affSColin Finck HRESULT WINAPI
DllCanUnloadNow(VOID)206*c2c66affSColin Finck DllCanUnloadNow(VOID)
207*c2c66affSColin Finck {
208*c2c66affSColin Finck     return dll_refs == 0 ? S_OK : S_FALSE;
209*c2c66affSColin Finck }
210