1 | /*
|
---|
2 | * Implements IMoniker for CLSID_CDeviceMoniker.
|
---|
3 | *
|
---|
4 | * hidenori@a2.ctktv.ne.jp
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "config.h"
|
---|
8 |
|
---|
9 | #include "windef.h"
|
---|
10 | #include "winbase.h"
|
---|
11 | #include "wingdi.h"
|
---|
12 | #include "winuser.h"
|
---|
13 | #include "winreg.h"
|
---|
14 | #include "winerror.h"
|
---|
15 | #include "wine/obj_base.h"
|
---|
16 | #include "objidl.h"
|
---|
17 | #include "oleidl.h"
|
---|
18 | #include "ocidl.h"
|
---|
19 | #include "oleauto.h"
|
---|
20 | #include "strmif.h"
|
---|
21 | #include "uuids.h"
|
---|
22 | #include "wine/unicode.h"
|
---|
23 |
|
---|
24 | #include "debugtools.h"
|
---|
25 | DEFAULT_DEBUG_CHANNEL(quartz);
|
---|
26 |
|
---|
27 | #include "quartz_private.h"
|
---|
28 | #include "devmon.h"
|
---|
29 | #include "monprop.h"
|
---|
30 | #include "regsvr.h"
|
---|
31 |
|
---|
32 |
|
---|
33 | static HRESULT WINAPI
|
---|
34 | IMoniker_fnQueryInterface(IMoniker* iface,REFIID riid,void** ppobj)
|
---|
35 | {
|
---|
36 | CDeviceMoniker_THIS(iface,moniker);
|
---|
37 |
|
---|
38 | TRACE("(%p)->()\n",This);
|
---|
39 |
|
---|
40 | return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
|
---|
41 | }
|
---|
42 |
|
---|
43 | static ULONG WINAPI
|
---|
44 | IMoniker_fnAddRef(IMoniker* iface)
|
---|
45 | {
|
---|
46 | CDeviceMoniker_THIS(iface,moniker);
|
---|
47 |
|
---|
48 | TRACE("(%p)->()\n",This);
|
---|
49 |
|
---|
50 | return IUnknown_AddRef(This->unk.punkControl);
|
---|
51 | }
|
---|
52 |
|
---|
53 | static ULONG WINAPI
|
---|
54 | IMoniker_fnRelease(IMoniker* iface)
|
---|
55 | {
|
---|
56 | CDeviceMoniker_THIS(iface,moniker);
|
---|
57 |
|
---|
58 | TRACE("(%p)->()\n",This);
|
---|
59 |
|
---|
60 | return IUnknown_Release(This->unk.punkControl);
|
---|
61 | }
|
---|
62 |
|
---|
63 | static HRESULT WINAPI IMoniker_fnGetClassID(IMoniker* iface, CLSID *pClassID)
|
---|
64 | {
|
---|
65 | CDeviceMoniker_THIS(iface,moniker);
|
---|
66 |
|
---|
67 | TRACE("(%p)->()\n",This);
|
---|
68 |
|
---|
69 | if ( pClassID == NULL )
|
---|
70 | return E_POINTER;
|
---|
71 | memcpy( pClassID, &CLSID_CDeviceMoniker, sizeof(CLSID) );
|
---|
72 |
|
---|
73 | return NOERROR;
|
---|
74 | }
|
---|
75 |
|
---|
76 | static HRESULT WINAPI IMoniker_fnIsDirty(IMoniker* iface)
|
---|
77 | {
|
---|
78 | CDeviceMoniker_THIS(iface,moniker);
|
---|
79 |
|
---|
80 | FIXME("(%p)->() stub!\n",This);
|
---|
81 |
|
---|
82 | return E_NOTIMPL;
|
---|
83 | }
|
---|
84 |
|
---|
85 | static HRESULT WINAPI IMoniker_fnLoad(IMoniker* iface, IStream* pStm)
|
---|
86 | {
|
---|
87 | CDeviceMoniker_THIS(iface,moniker);
|
---|
88 |
|
---|
89 | FIXME("(%p)->() stub!\n",This);
|
---|
90 |
|
---|
91 | return E_NOTIMPL;
|
---|
92 | }
|
---|
93 |
|
---|
94 | static HRESULT WINAPI IMoniker_fnSave(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
|
---|
95 | {
|
---|
96 | CDeviceMoniker_THIS(iface,moniker);
|
---|
97 |
|
---|
98 | FIXME("(%p)->() stub!\n",This);
|
---|
99 |
|
---|
100 | return E_NOTIMPL;
|
---|
101 | }
|
---|
102 |
|
---|
103 | static HRESULT WINAPI IMoniker_fnGetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize)
|
---|
104 | {
|
---|
105 | CDeviceMoniker_THIS(iface,moniker);
|
---|
106 |
|
---|
107 | FIXME("(%p)->() stub!\n",This);
|
---|
108 |
|
---|
109 | return E_NOTIMPL;
|
---|
110 | }
|
---|
111 |
|
---|
112 | static HRESULT WINAPI IMoniker_fnBindToObject(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult)
|
---|
113 | {
|
---|
114 | CDeviceMoniker_THIS(iface,moniker);
|
---|
115 | HRESULT hr;
|
---|
116 | IPropertyBag* pPropBag;
|
---|
117 | VARIANT vClsid;
|
---|
118 | CLSID clsid;
|
---|
119 |
|
---|
120 | TRACE("(%p)->(%p,%p,%s,%p)\n",This,
|
---|
121 | pbc,pmkToLeft,debugstr_guid(riid),ppvResult);
|
---|
122 | if ( pbc != NULL )
|
---|
123 | {
|
---|
124 | FIXME("IBindCtx* pbc != NULL not implemented.\n");
|
---|
125 | return E_FAIL;
|
---|
126 | }
|
---|
127 | if ( pmkToLeft != NULL )
|
---|
128 | {
|
---|
129 | FIXME("IMoniker* pmkToLeft != NULL not implemented.\n");
|
---|
130 | return E_FAIL;
|
---|
131 | }
|
---|
132 | if ( ppvResult == NULL )
|
---|
133 | return E_POINTER;
|
---|
134 |
|
---|
135 | hr = QUARTZ_CreateRegPropertyBag(
|
---|
136 | This->m_hkRoot, This->m_pwszPath, &pPropBag );
|
---|
137 | if ( FAILED(hr) )
|
---|
138 | return hr;
|
---|
139 |
|
---|
140 | vClsid.n1.n2.vt = VT_BSTR;
|
---|
141 | hr = IPropertyBag_Read(
|
---|
142 | pPropBag, QUARTZ_wszCLSID, &vClsid, NULL );
|
---|
143 | IPropertyBag_Release( pPropBag );
|
---|
144 | if ( FAILED(hr) )
|
---|
145 | return hr;
|
---|
146 |
|
---|
147 | hr = CLSIDFromString( vClsid.n1.n2.n3.bstrVal, &clsid );
|
---|
148 | SysFreeString(vClsid.n1.n2.n3.bstrVal);
|
---|
149 | if ( FAILED(hr) )
|
---|
150 | return hr;
|
---|
151 |
|
---|
152 | return CoCreateInstance(
|
---|
153 | &clsid, NULL, CLSCTX_INPROC_SERVER, riid, ppvResult );
|
---|
154 | }
|
---|
155 |
|
---|
156 | static HRESULT WINAPI IMoniker_fnBindToStorage(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult)
|
---|
157 | {
|
---|
158 | CDeviceMoniker_THIS(iface,moniker);
|
---|
159 | HRESULT hr;
|
---|
160 |
|
---|
161 | TRACE("(%p)->(%p,%p,%s,%p)\n",This,
|
---|
162 | pbc,pmkToLeft,debugstr_guid(riid),ppvResult);
|
---|
163 | if ( pbc != NULL )
|
---|
164 | {
|
---|
165 | FIXME("IBindCtx* pbc != NULL not implemented.\n");
|
---|
166 | return E_FAIL;
|
---|
167 | }
|
---|
168 | if ( pmkToLeft != NULL )
|
---|
169 | {
|
---|
170 | FIXME("IMoniker* pmkToLeft != NULL not implemented.\n");
|
---|
171 | return E_FAIL;
|
---|
172 | }
|
---|
173 | if ( ppvResult == NULL )
|
---|
174 | return E_POINTER;
|
---|
175 |
|
---|
176 | hr = E_NOINTERFACE;
|
---|
177 | if ( IsEqualGUID(riid,&IID_IUnknown) ||
|
---|
178 | IsEqualGUID(riid,&IID_IPropertyBag) )
|
---|
179 | {
|
---|
180 | hr = QUARTZ_CreateRegPropertyBag(
|
---|
181 | This->m_hkRoot, This->m_pwszPath,
|
---|
182 | (IPropertyBag**)ppvResult );
|
---|
183 | }
|
---|
184 |
|
---|
185 | return hr;
|
---|
186 | }
|
---|
187 |
|
---|
188 | static HRESULT WINAPI IMoniker_fnReduce(IMoniker* iface,IBindCtx* pbc, DWORD dwReduceHowFar,IMoniker** ppmkToLeft, IMoniker** ppmkReduced)
|
---|
189 | {
|
---|
190 | CDeviceMoniker_THIS(iface,moniker);
|
---|
191 |
|
---|
192 | TRACE("(%p)->()\n",This);
|
---|
193 |
|
---|
194 | if ( ppmkReduced == NULL )
|
---|
195 | return E_POINTER;
|
---|
196 |
|
---|
197 | *ppmkReduced = iface; IMoniker_AddRef(iface);
|
---|
198 |
|
---|
199 | return MK_S_REDUCED_TO_SELF;
|
---|
200 | }
|
---|
201 |
|
---|
202 | static HRESULT WINAPI IMoniker_fnComposeWith(IMoniker* iface,IMoniker* pmkRight,BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite)
|
---|
203 | {
|
---|
204 | CDeviceMoniker_THIS(iface,moniker);
|
---|
205 |
|
---|
206 | FIXME("(%p)->() stub!\n",This);
|
---|
207 |
|
---|
208 | return E_NOTIMPL;
|
---|
209 | }
|
---|
210 |
|
---|
211 | static HRESULT WINAPI IMoniker_fnEnum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
|
---|
212 | {
|
---|
213 | CDeviceMoniker_THIS(iface,moniker);
|
---|
214 |
|
---|
215 | TRACE("(%p)->()\n",This);
|
---|
216 |
|
---|
217 | if ( ppenumMoniker == NULL )
|
---|
218 | return E_POINTER;
|
---|
219 |
|
---|
220 | *ppenumMoniker = NULL;
|
---|
221 | return NOERROR;
|
---|
222 | }
|
---|
223 |
|
---|
224 | static HRESULT WINAPI IMoniker_fnIsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
|
---|
225 | {
|
---|
226 | CDeviceMoniker_THIS(iface,moniker);
|
---|
227 |
|
---|
228 | FIXME("(%p)->() stub!\n",This);
|
---|
229 |
|
---|
230 | return E_NOTIMPL;
|
---|
231 | }
|
---|
232 |
|
---|
233 | static HRESULT WINAPI IMoniker_fnHash(IMoniker* iface,DWORD* pdwHash)
|
---|
234 | {
|
---|
235 | CDeviceMoniker_THIS(iface,moniker);
|
---|
236 |
|
---|
237 | FIXME("(%p)->() stub!\n",This);
|
---|
238 |
|
---|
239 | return E_NOTIMPL;
|
---|
240 | }
|
---|
241 |
|
---|
242 | static HRESULT WINAPI IMoniker_fnIsRunning(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, IMoniker* pmkNewlyRunning)
|
---|
243 | {
|
---|
244 | CDeviceMoniker_THIS(iface,moniker);
|
---|
245 |
|
---|
246 | FIXME("(%p)->() stub!\n",This);
|
---|
247 |
|
---|
248 | return E_NOTIMPL;
|
---|
249 | }
|
---|
250 |
|
---|
251 | static HRESULT WINAPI IMoniker_fnGetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, FILETIME* pCompositeTime)
|
---|
252 | {
|
---|
253 | CDeviceMoniker_THIS(iface,moniker);
|
---|
254 |
|
---|
255 | FIXME("(%p)->() stub!\n",This);
|
---|
256 |
|
---|
257 | return E_NOTIMPL;
|
---|
258 | }
|
---|
259 |
|
---|
260 | static HRESULT WINAPI IMoniker_fnInverse(IMoniker* iface,IMoniker** ppmk)
|
---|
261 | {
|
---|
262 | CDeviceMoniker_THIS(iface,moniker);
|
---|
263 |
|
---|
264 | FIXME("(%p)->() stub!\n",This);
|
---|
265 |
|
---|
266 | return E_NOTIMPL;
|
---|
267 | }
|
---|
268 |
|
---|
269 | static HRESULT WINAPI IMoniker_fnCommonPrefixWith(IMoniker* iface,IMoniker* pmkOther, IMoniker** ppmkPrefix)
|
---|
270 | {
|
---|
271 | CDeviceMoniker_THIS(iface,moniker);
|
---|
272 |
|
---|
273 | FIXME("(%p)->() stub!\n",This);
|
---|
274 |
|
---|
275 | return E_NOTIMPL;
|
---|
276 | }
|
---|
277 |
|
---|
278 | static HRESULT WINAPI IMoniker_fnRelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
|
---|
279 | {
|
---|
280 | CDeviceMoniker_THIS(iface,moniker);
|
---|
281 |
|
---|
282 | FIXME("(%p)->() stub!\n",This);
|
---|
283 |
|
---|
284 | return E_NOTIMPL;
|
---|
285 | }
|
---|
286 |
|
---|
287 | static HRESULT WINAPI IMoniker_fnGetDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName)
|
---|
288 | {
|
---|
289 | CDeviceMoniker_THIS(iface,moniker);
|
---|
290 |
|
---|
291 | FIXME("(%p)->() stub!\n",This);
|
---|
292 |
|
---|
293 | return E_NOTIMPL;
|
---|
294 | }
|
---|
295 |
|
---|
296 | static HRESULT WINAPI IMoniker_fnParseDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut)
|
---|
297 | {
|
---|
298 | CDeviceMoniker_THIS(iface,moniker);
|
---|
299 |
|
---|
300 | FIXME("(%p)->() stub!\n",This);
|
---|
301 |
|
---|
302 | return E_NOTIMPL;
|
---|
303 | }
|
---|
304 |
|
---|
305 | static HRESULT WINAPI IMoniker_fnIsSystemMoniker(IMoniker* iface,DWORD* pdwMksys)
|
---|
306 | {
|
---|
307 | CDeviceMoniker_THIS(iface,moniker);
|
---|
308 |
|
---|
309 | TRACE("(%p)->()\n",This);
|
---|
310 | if ( pdwMksys == NULL )
|
---|
311 | return E_POINTER;
|
---|
312 |
|
---|
313 | *pdwMksys = MKSYS_NONE;
|
---|
314 | return S_FALSE;
|
---|
315 | }
|
---|
316 |
|
---|
317 |
|
---|
318 | static ICOM_VTABLE(IMoniker) imoniker =
|
---|
319 | {
|
---|
320 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
321 | /* IUnknown fields */
|
---|
322 | IMoniker_fnQueryInterface,
|
---|
323 | IMoniker_fnAddRef,
|
---|
324 | IMoniker_fnRelease,
|
---|
325 | /* IPersist fields */
|
---|
326 | IMoniker_fnGetClassID,
|
---|
327 | /* IPersistStream fields */
|
---|
328 | IMoniker_fnIsDirty,
|
---|
329 | IMoniker_fnLoad,
|
---|
330 | IMoniker_fnSave,
|
---|
331 | IMoniker_fnGetSizeMax,
|
---|
332 | /* IMoniker fields */
|
---|
333 | IMoniker_fnBindToObject,
|
---|
334 | IMoniker_fnBindToStorage,
|
---|
335 | IMoniker_fnReduce,
|
---|
336 | IMoniker_fnComposeWith,
|
---|
337 | IMoniker_fnEnum,
|
---|
338 | IMoniker_fnIsEqual,
|
---|
339 | IMoniker_fnHash,
|
---|
340 | IMoniker_fnIsRunning,
|
---|
341 | IMoniker_fnGetTimeOfLastChange,
|
---|
342 | IMoniker_fnInverse,
|
---|
343 | IMoniker_fnCommonPrefixWith,
|
---|
344 | IMoniker_fnRelativePathTo,
|
---|
345 | IMoniker_fnGetDisplayName,
|
---|
346 | IMoniker_fnParseDisplayName,
|
---|
347 | IMoniker_fnIsSystemMoniker,
|
---|
348 | };
|
---|
349 |
|
---|
350 |
|
---|
351 | static HRESULT CDeviceMoniker_InitIMoniker(
|
---|
352 | CDeviceMoniker* pdm, HKEY hkRoot, LPCWSTR lpKeyPath )
|
---|
353 | {
|
---|
354 | DWORD dwLen;
|
---|
355 |
|
---|
356 | ICOM_VTBL(&pdm->moniker) = &imoniker;
|
---|
357 | pdm->m_hkRoot = hkRoot;
|
---|
358 | pdm->m_pwszPath = NULL;
|
---|
359 |
|
---|
360 | dwLen = sizeof(WCHAR)*(strlenW(lpKeyPath)+1);
|
---|
361 | pdm->m_pwszPath = (WCHAR*)QUARTZ_AllocMem( dwLen );
|
---|
362 | if ( pdm->m_pwszPath == NULL )
|
---|
363 | return E_OUTOFMEMORY;
|
---|
364 | memcpy( pdm->m_pwszPath, lpKeyPath, dwLen );
|
---|
365 |
|
---|
366 | return NOERROR;
|
---|
367 | }
|
---|
368 |
|
---|
369 | static void CDeviceMoniker_UninitIMoniker(
|
---|
370 | CDeviceMoniker* pdm )
|
---|
371 | {
|
---|
372 | if ( pdm->m_pwszPath != NULL )
|
---|
373 | QUARTZ_FreeMem( pdm->m_pwszPath );
|
---|
374 | }
|
---|
375 |
|
---|
376 |
|
---|
377 | static void QUARTZ_DestroyDeviceMoniker(IUnknown* punk)
|
---|
378 | {
|
---|
379 | CDeviceMoniker_THIS(punk,unk);
|
---|
380 |
|
---|
381 | CDeviceMoniker_UninitIMoniker( This );
|
---|
382 | }
|
---|
383 |
|
---|
384 | /* can I use offsetof safely? - FIXME? */
|
---|
385 | static QUARTZ_IFEntry IFEntries[] =
|
---|
386 | {
|
---|
387 | { &IID_IPersist, offsetof(CDeviceMoniker,moniker)-offsetof(CDeviceMoniker,unk) },
|
---|
388 | { &IID_IPersistStream, offsetof(CDeviceMoniker,moniker)-offsetof(CDeviceMoniker,unk) },
|
---|
389 | { &IID_IMoniker, offsetof(CDeviceMoniker,moniker)-offsetof(CDeviceMoniker,unk) },
|
---|
390 | };
|
---|
391 |
|
---|
392 | HRESULT QUARTZ_CreateDeviceMoniker(
|
---|
393 | HKEY hkRoot, LPCWSTR lpKeyPath,
|
---|
394 | IMoniker** ppMoniker )
|
---|
395 | {
|
---|
396 | CDeviceMoniker* pdm;
|
---|
397 | HRESULT hr;
|
---|
398 |
|
---|
399 | TRACE("(%08x,%s,%p)\n",hkRoot,debugstr_w(lpKeyPath),ppMoniker );
|
---|
400 |
|
---|
401 | pdm = (CDeviceMoniker*)QUARTZ_AllocObj( sizeof(CDeviceMoniker) );
|
---|
402 | if ( pdm == NULL )
|
---|
403 | return E_OUTOFMEMORY;
|
---|
404 |
|
---|
405 | QUARTZ_IUnkInit( &pdm->unk, NULL );
|
---|
406 | hr = CDeviceMoniker_InitIMoniker( pdm, hkRoot, lpKeyPath );
|
---|
407 | if ( FAILED(hr) )
|
---|
408 | {
|
---|
409 | QUARTZ_FreeObj( pdm );
|
---|
410 | return hr;
|
---|
411 | }
|
---|
412 |
|
---|
413 | pdm->unk.pEntries = IFEntries;
|
---|
414 | pdm->unk.dwEntries = sizeof(IFEntries)/sizeof(IFEntries[0]);
|
---|
415 | pdm->unk.pOnFinalRelease = &QUARTZ_DestroyDeviceMoniker;
|
---|
416 |
|
---|
417 | *ppMoniker = (IMoniker*)(&pdm->moniker);
|
---|
418 |
|
---|
419 | return S_OK;
|
---|
420 | }
|
---|
421 |
|
---|
422 |
|
---|