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