2 * IFilterMapper & IFilterMapper2 Implementations
4 * Copyright 2003 Robert Shearman
5 * Copyright 2004 Christian Costa
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define NONAMELESSUNION
23 #define NONAMELESSSTRUCT
32 #include "quartz_private.h"
34 #define COM_NO_WINDOWS_H
38 #include "wine/unicode.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
45 typedef struct FilterMapper2Impl
47 const IFilterMapper2Vtbl
*lpVtbl
;
48 const IFilterMapperVtbl
*lpVtblFilterMapper
;
52 static const IFilterMapper2Vtbl fm2vtbl
;
53 static const IFilterMapperVtbl fmvtbl
;
55 static inline FilterMapper2Impl
*impl_from_IFilterMapper( IFilterMapper
*iface
)
57 return (FilterMapper2Impl
*)((char*)iface
- FIELD_OFFSET(FilterMapper2Impl
, lpVtblFilterMapper
));
60 static const WCHAR wszClsidSlash
[] = {'C','L','S','I','D','\\',0};
61 static const WCHAR wszSlashInstance
[] = {'\\','I','n','s','t','a','n','c','e','\\',0};
62 static const WCHAR wszSlash
[] = {'\\',0};
64 /* CLSID property in media category Moniker */
65 static const WCHAR wszClsidName
[] = {'C','L','S','I','D',0};
66 /* FriendlyName property in media category Moniker */
67 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
68 /* Merit property in media category Moniker (CLSID_ActiveMovieCategories only) */
69 static const WCHAR wszMeritName
[] = {'M','e','r','i','t',0};
70 /* FilterData property in media category Moniker (not CLSID_ActiveMovieCategories) */
71 static const WCHAR wszFilterDataName
[] = {'F','i','l','t','e','r','D','a','t','a',0};
72 /* For filters registered with IFilterMapper */
73 static const WCHAR wszFilterSlash
[] = {'F','i','l','t','e','r','\\',0};
74 static const WCHAR wszFilter
[] = {'F','i','l','t','e','r',0};
75 /* For pins registered with IFilterMapper */
76 static const WCHAR wszPins
[] = {'P','i','n','s',0};
77 static const WCHAR wszAllowedMany
[] = {'A','l','l','o','w','e','d','M','a','n','y',0};
78 static const WCHAR wszAllowedZero
[] = {'A','l','l','o','w','e','d','Z','e','r','o',0};
79 static const WCHAR wszDirection
[] = {'D','i','r','e','c','t','i','o','n',0};
80 static const WCHAR wszIsRendered
[] = {'I','s','R','e','n','d','e','r','e','d',0};
81 /* For types registered with IFilterMapper */
82 static const WCHAR wszTypes
[] = {'T','y','p','e','s',0};
85 /* registry format for REGFILTER2 */
96 BYTE signature
[4]; /* e.g. "0pi3" */
101 DWORD bCategory
; /* is there a category clsid? */
102 /* optional: dwOffsetCategoryClsid */
107 BYTE signature
[4]; /* e.g. "0ty3" */
122 int capacity
; /* in bytes */
123 int current
; /* pointer to next free byte */
126 /* returns the position it was added at */
127 static int add_data(struct Vector
* v
, const BYTE
* pData
, int size
)
129 int index
= v
->current
;
130 if (v
->current
+ size
> v
->capacity
)
132 LPBYTE pOldData
= v
->pData
;
133 v
->capacity
= (v
->capacity
+ size
) * 2;
134 v
->pData
= CoTaskMemAlloc(v
->capacity
);
135 memcpy(v
->pData
, pOldData
, v
->current
);
136 CoTaskMemFree(pOldData
);
138 memcpy(v
->pData
+ v
->current
, pData
, size
);
143 static int find_data(struct Vector
* v
, const BYTE
* pData
, int size
)
146 for (index
= 0; index
< v
->current
; index
++)
147 if (!memcmp(v
->pData
+ index
, pData
, size
))
153 static void delete_vector(struct Vector
* v
)
155 CoTaskMemFree(v
->pData
);
160 HRESULT
FilterMapper2_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
162 FilterMapper2Impl
* pFM2impl
;
164 TRACE("(%p, %p)\n", pUnkOuter
, ppObj
);
167 return CLASS_E_NOAGGREGATION
;
169 pFM2impl
= CoTaskMemAlloc(sizeof(*pFM2impl
));
171 return E_OUTOFMEMORY
;
173 pFM2impl
->lpVtbl
= &fm2vtbl
;
174 pFM2impl
->lpVtblFilterMapper
= &fmvtbl
;
175 pFM2impl
->refCount
= 1;
179 TRACE("-- created at %p\n", pFM2impl
);
184 /*** IUnknown methods ***/
186 static HRESULT WINAPI
FilterMapper2_QueryInterface(IFilterMapper2
* iface
, REFIID riid
, LPVOID
*ppv
)
188 FilterMapper2Impl
*This
= (FilterMapper2Impl
*)iface
;
190 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppv
);
194 if (IsEqualIID(riid
, &IID_IUnknown
))
196 else if (IsEqualIID(riid
, &IID_IFilterMapper2
))
198 else if (IsEqualIID(riid
, &IID_IFilterMapper
))
199 *ppv
= &This
->lpVtblFilterMapper
;
203 IUnknown_AddRef((IUnknown
*)*ppv
);
207 FIXME("No interface for %s\n", debugstr_guid(riid
));
208 return E_NOINTERFACE
;
211 static ULONG WINAPI
FilterMapper2_AddRef(IFilterMapper2
* iface
)
213 FilterMapper2Impl
*This
= (FilterMapper2Impl
*)iface
;
214 ULONG refCount
= InterlockedIncrement(&This
->refCount
);
216 TRACE("(%p)->()\n", iface
);
221 static ULONG WINAPI
FilterMapper2_Release(IFilterMapper2
* iface
)
223 FilterMapper2Impl
*This
= (FilterMapper2Impl
*)iface
;
224 ULONG refCount
= InterlockedDecrement(&This
->refCount
);
226 TRACE("(%p)->()\n", iface
);
236 /*** IFilterMapper2 methods ***/
238 static HRESULT WINAPI
FilterMapper2_CreateCategory(
239 IFilterMapper2
* iface
,
240 REFCLSID clsidCategory
,
241 DWORD dwCategoryMerit
,
242 LPCWSTR szDescription
)
244 LPWSTR wClsidAMCat
= NULL
;
245 LPWSTR wClsidCategory
= NULL
;
246 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + strlenW(wszSlashInstance
) + (CHARS_IN_GUID
-1) * 2 + 1];
251 TRACE("(%s, %x, %s)\n", debugstr_guid(clsidCategory
), dwCategoryMerit
, debugstr_w(szDescription
));
253 hr
= StringFromCLSID(&CLSID_ActiveMovieCategories
, &wClsidAMCat
);
257 hr
= StringFromCLSID(clsidCategory
, &wClsidCategory
);
262 strcpyW(wszKeyName
, wszClsidSlash
);
263 strcatW(wszKeyName
, wClsidAMCat
);
264 strcatW(wszKeyName
, wszSlashInstance
);
265 strcatW(wszKeyName
, wClsidCategory
);
267 lRet
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
);
268 hr
= HRESULT_FROM_WIN32(lRet
);
273 lRet
= RegSetValueExW(hKey
, wszFriendlyName
, 0, REG_SZ
, (const BYTE
*)szDescription
, (strlenW(szDescription
) + 1) * sizeof(WCHAR
));
274 hr
= HRESULT_FROM_WIN32(lRet
);
279 lRet
= RegSetValueExW(hKey
, wszClsidName
, 0, REG_SZ
, (LPBYTE
)wClsidCategory
, (strlenW(wClsidCategory
) + 1) * sizeof(WCHAR
));
280 hr
= HRESULT_FROM_WIN32(lRet
);
285 lRet
= RegSetValueExW(hKey
, wszMeritName
, 0, REG_DWORD
, (LPBYTE
)&dwCategoryMerit
, sizeof(dwCategoryMerit
));
286 hr
= HRESULT_FROM_WIN32(lRet
);
290 CoTaskMemFree(wClsidCategory
);
291 CoTaskMemFree(wClsidAMCat
);
296 static HRESULT WINAPI
FilterMapper2_UnregisterFilter(
297 IFilterMapper2
* iface
,
298 const CLSID
*pclsidCategory
,
299 const OLECHAR
*szInstance
,
302 WCHAR wszKeyName
[MAX_PATH
];
303 LPWSTR wClsidCategory
= NULL
;
304 LPWSTR wFilter
= NULL
;
307 TRACE("(%p, %s, %s)\n", pclsidCategory
, debugstr_w(szInstance
), debugstr_guid(Filter
));
310 pclsidCategory
= &CLSID_LegacyAmFilterCategory
;
312 hr
= StringFromCLSID(pclsidCategory
, &wClsidCategory
);
316 strcpyW(wszKeyName
, wszClsidSlash
);
317 strcatW(wszKeyName
, wClsidCategory
);
318 strcatW(wszKeyName
, wszSlashInstance
);
320 strcatW(wszKeyName
, szInstance
);
323 hr
= StringFromCLSID(Filter
, &wFilter
);
325 strcatW(wszKeyName
, wFilter
);
331 LONG lRet
= RegDeleteKeyW(HKEY_CLASSES_ROOT
, wszKeyName
);
332 hr
= HRESULT_FROM_WIN32(lRet
);
335 CoTaskMemFree(wClsidCategory
);
336 CoTaskMemFree(wFilter
);
341 static HRESULT
FM2_WriteFriendlyName(IPropertyBag
* pPropBag
, LPCWSTR szName
)
345 V_VT(&var
) = VT_BSTR
;
346 V_UNION(&var
, bstrVal
) = (BSTR
)szName
;
348 return IPropertyBag_Write(pPropBag
, wszFriendlyName
, &var
);
351 static HRESULT
FM2_WriteClsid(IPropertyBag
* pPropBag
, REFCLSID clsid
)
353 LPWSTR wszClsid
= NULL
;
357 hr
= StringFromCLSID(clsid
, &wszClsid
);
361 V_VT(&var
) = VT_BSTR
;
362 V_UNION(&var
, bstrVal
) = wszClsid
;
363 hr
= IPropertyBag_Write(pPropBag
, wszClsidName
, &var
);
365 CoTaskMemFree(wszClsid
);
369 static HRESULT
FM2_WriteFilterData(IPropertyBag
* pPropBag
, const REGFILTER2
* prf2
)
372 int size
= sizeof(struct REG_RF
);
374 struct Vector mainStore
= {NULL
, 0, 0};
375 struct Vector clsidStore
= {NULL
, 0, 0};
378 SAFEARRAYBOUND saBound
;
381 rrf
.dwVersion
= prf2
->dwVersion
;
382 rrf
.dwMerit
= prf2
->dwMerit
;
383 rrf
.dwPins
= prf2
->u
.s1
.cPins2
;
386 add_data(&mainStore
, (LPBYTE
)&rrf
, sizeof(rrf
));
388 for (i
= 0; i
< prf2
->u
.s1
.cPins2
; i
++)
390 size
+= sizeof(struct REG_RFP
);
391 if (prf2
->u
.s1
.rgPins2
[i
].clsPinCategory
)
392 size
+= sizeof(DWORD
);
393 size
+= prf2
->u
.s1
.rgPins2
[i
].nMediaTypes
* sizeof(struct REG_TYPE
);
394 size
+= prf2
->u
.s1
.rgPins2
[i
].nMediums
* sizeof(DWORD
);
397 for (i
= 0; i
< prf2
->u
.s1
.cPins2
; i
++)
400 REGFILTERPINS2 rgPin2
= prf2
->u
.s1
.rgPins2
[i
];
403 rrfp
.signature
[0] = '0';
404 rrfp
.signature
[1] = 'p';
405 rrfp
.signature
[2] = 'i';
406 rrfp
.signature
[3] = '3';
407 rrfp
.signature
[0] += i
;
408 rrfp
.dwFlags
= rgPin2
.dwFlags
;
409 rrfp
.dwInstances
= rgPin2
.cInstances
;
410 rrfp
.dwMediaTypes
= rgPin2
.nMediaTypes
;
411 rrfp
.dwMediums
= rgPin2
.nMediums
;
412 rrfp
.bCategory
= rgPin2
.clsPinCategory
? 1 : 0;
414 add_data(&mainStore
, (LPBYTE
)&rrfp
, sizeof(rrfp
));
417 DWORD index
= find_data(&clsidStore
, (const BYTE
*)rgPin2
.clsPinCategory
, sizeof(CLSID
));
419 index
= add_data(&clsidStore
, (const BYTE
*)rgPin2
.clsPinCategory
, sizeof(CLSID
));
422 add_data(&mainStore
, (LPBYTE
)&index
, sizeof(index
));
425 for (j
= 0; j
< rgPin2
.nMediaTypes
; j
++)
428 rt
.signature
[0] = '0';
429 rt
.signature
[1] = 't';
430 rt
.signature
[2] = 'y';
431 rt
.signature
[3] = '3';
432 rt
.signature
[0] += j
;
435 rt
.dwOffsetMajor
= find_data(&clsidStore
, (const BYTE
*)rgPin2
.lpMediaType
[j
].clsMajorType
, sizeof(CLSID
));
436 if (rt
.dwOffsetMajor
== -1)
437 rt
.dwOffsetMajor
= add_data(&clsidStore
, (const BYTE
*)rgPin2
.lpMediaType
[j
].clsMajorType
, sizeof(CLSID
));
438 rt
.dwOffsetMajor
+= size
;
439 rt
.dwOffsetMinor
= find_data(&clsidStore
, (const BYTE
*)rgPin2
.lpMediaType
[j
].clsMinorType
, sizeof(CLSID
));
440 if (rt
.dwOffsetMinor
== -1)
441 rt
.dwOffsetMinor
= add_data(&clsidStore
, (const BYTE
*)rgPin2
.lpMediaType
[j
].clsMinorType
, sizeof(CLSID
));
442 rt
.dwOffsetMinor
+= size
;
444 add_data(&mainStore
, (LPBYTE
)&rt
, sizeof(rt
));
447 for (j
= 0; j
< rgPin2
.nMediums
; j
++)
449 DWORD index
= find_data(&clsidStore
, (const BYTE
*)(rgPin2
.lpMedium
+ j
), sizeof(REGPINMEDIUM
));
451 index
= add_data(&clsidStore
, (const BYTE
*)(rgPin2
.lpMedium
+ j
), sizeof(REGPINMEDIUM
));
454 add_data(&mainStore
, (LPBYTE
)&index
, sizeof(index
));
459 saBound
.cElements
= mainStore
.current
+ clsidStore
.current
;
460 psa
= SafeArrayCreate(VT_UI1
, 1, &saBound
);
463 ERR("Couldn't create SAFEARRAY\n");
470 hr
= SafeArrayAccessData(psa
, (LPVOID
*)&pbSAData
);
473 memcpy(pbSAData
, mainStore
.pData
, mainStore
.current
);
474 memcpy(pbSAData
+ mainStore
.current
, clsidStore
.pData
, clsidStore
.current
);
475 hr
= SafeArrayUnaccessData(psa
);
479 V_VT(&var
) = VT_ARRAY
| VT_UI1
;
480 V_UNION(&var
, parray
) = psa
;
483 hr
= IPropertyBag_Write(pPropBag
, wszFilterDataName
, &var
);
486 SafeArrayDestroy(psa
);
488 delete_vector(&mainStore
);
489 delete_vector(&clsidStore
);
493 static HRESULT
FM2_ReadFilterData(IPropertyBag
* pPropBag
, REGFILTER2
* prf2
)
498 struct REG_RF
* prrf
;
501 REGFILTERPINS2
* rgPins2
;
504 V_VT(&var
) = VT_ARRAY
| VT_UI1
;
506 hr
= IPropertyBag_Read(pPropBag
, wszFilterDataName
, &var
, NULL
);
509 hr
= SafeArrayAccessData(V_UNION(&var
, parray
), (LPVOID
*)&pData
);
513 prrf
= (struct REG_RF
*)pData
;
516 if (prrf
->dwVersion
!= 2)
518 FIXME("Filter registry version %d not supported\n", prrf
->dwVersion
);
519 ZeroMemory(prf2
, sizeof(*prf2
));
526 TRACE("version = %d, merit = %x, #pins = %d, unused = %x\n",
527 prrf
->dwVersion
, prrf
->dwMerit
, prrf
->dwPins
, prrf
->dwUnused
);
529 prf2
->dwVersion
= prrf
->dwVersion
;
530 prf2
->dwMerit
= prrf
->dwMerit
;
531 prf2
->u
.s1
.cPins2
= prrf
->dwPins
;
532 rgPins2
= CoTaskMemAlloc(prrf
->dwPins
* sizeof(*rgPins2
));
533 prf2
->u
.s1
.rgPins2
= rgPins2
;
534 pCurrent
+= sizeof(struct REG_RF
);
536 for (i
= 0; i
< prrf
->dwPins
; i
++)
538 struct REG_RFP
* prrfp
= (struct REG_RFP
*)pCurrent
;
539 REGPINTYPES
* lpMediaType
;
540 REGPINMEDIUM
* lpMedium
;
543 /* FIXME: check signature */
545 TRACE("\tsignature = %s\n", debugstr_an((const char*)prrfp
->signature
, 4));
547 TRACE("\tpin[%d]: flags = %x, instances = %d, media types = %d, mediums = %d\n",
548 i
, prrfp
->dwFlags
, prrfp
->dwInstances
, prrfp
->dwMediaTypes
, prrfp
->dwMediums
);
550 rgPins2
[i
].dwFlags
= prrfp
->dwFlags
;
551 rgPins2
[i
].cInstances
= prrfp
->dwInstances
;
552 rgPins2
[i
].nMediaTypes
= prrfp
->dwMediaTypes
;
553 rgPins2
[i
].nMediums
= prrfp
->dwMediums
;
554 pCurrent
+= sizeof(struct REG_RFP
);
555 if (prrfp
->bCategory
)
557 CLSID
* clsCat
= CoTaskMemAlloc(sizeof(CLSID
));
558 memcpy(clsCat
, pData
+ *(DWORD
*)(pCurrent
), sizeof(CLSID
));
559 pCurrent
+= sizeof(DWORD
);
560 rgPins2
[i
].clsPinCategory
= clsCat
;
563 rgPins2
[i
].clsPinCategory
= NULL
;
565 if (rgPins2
[i
].nMediaTypes
> 0)
566 lpMediaType
= CoTaskMemAlloc(rgPins2
[i
].nMediaTypes
* sizeof(*lpMediaType
));
570 rgPins2
[i
].lpMediaType
= lpMediaType
;
572 for (j
= 0; j
< rgPins2
[i
].nMediaTypes
; j
++)
574 struct REG_TYPE
* prt
= (struct REG_TYPE
*)pCurrent
;
575 CLSID
* clsMajor
= CoTaskMemAlloc(sizeof(CLSID
));
576 CLSID
* clsMinor
= CoTaskMemAlloc(sizeof(CLSID
));
578 /* FIXME: check signature */
579 TRACE("\t\tsignature = %s\n", debugstr_an((const char*)prt
->signature
, 4));
581 memcpy(clsMajor
, pData
+ prt
->dwOffsetMajor
, sizeof(CLSID
));
582 memcpy(clsMinor
, pData
+ prt
->dwOffsetMinor
, sizeof(CLSID
));
584 lpMediaType
[j
].clsMajorType
= clsMajor
;
585 lpMediaType
[j
].clsMinorType
= clsMinor
;
587 pCurrent
+= sizeof(*prt
);
590 if (rgPins2
[i
].nMediums
> 0)
591 lpMedium
= CoTaskMemAlloc(rgPins2
[i
].nMediums
* sizeof(*lpMedium
));
595 rgPins2
[i
].lpMedium
= lpMedium
;
597 for (j
= 0; j
< rgPins2
[i
].nMediums
; j
++)
599 DWORD dwOffset
= *(DWORD
*)pCurrent
;
601 memcpy(lpMedium
+ j
, pData
+ dwOffset
, sizeof(REGPINMEDIUM
));
603 pCurrent
+= sizeof(dwOffset
);
610 SafeArrayUnaccessData(V_UNION(&var
, parray
));
617 static void FM2_DeleteRegFilter(REGFILTER2
* prf2
)
620 for (i
= 0; i
< prf2
->u
.s1
.cPins2
; i
++)
623 if (prf2
->u
.s1
.rgPins2
[i
].clsPinCategory
)
624 CoTaskMemFree((LPVOID
)prf2
->u
.s1
.rgPins2
[i
].clsPinCategory
);
626 for (j
= 0; j
< prf2
->u
.s1
.rgPins2
[i
].nMediaTypes
; j
++)
628 CoTaskMemFree((LPVOID
)prf2
->u
.s1
.rgPins2
[i
].lpMediaType
[j
].clsMajorType
);
629 CoTaskMemFree((LPVOID
)prf2
->u
.s1
.rgPins2
[i
].lpMediaType
[j
].clsMinorType
);
631 CoTaskMemFree((LPVOID
)prf2
->u
.s1
.rgPins2
[i
].lpMedium
);
635 static HRESULT WINAPI
FilterMapper2_RegisterFilter(
636 IFilterMapper2
* iface
,
637 REFCLSID clsidFilter
,
639 IMoniker
**ppMoniker
,
640 const CLSID
*pclsidCategory
,
641 const OLECHAR
*szInstance
,
642 const REGFILTER2
*prf2
)
644 IParseDisplayName
* pParser
= NULL
;
645 IBindCtx
* pBindCtx
= NULL
;
646 IMoniker
* pMoniker
= NULL
;
647 IPropertyBag
* pPropBag
= NULL
;
649 LPWSTR pwszParseName
= NULL
;
651 static const WCHAR wszDevice
[] = {'@','d','e','v','i','c','e',':','s','w',':',0};
654 LPWSTR szClsidTemp
= NULL
;
655 REGFILTER2 regfilter2
;
656 REGFILTERPINS2
* pregfp2
= NULL
;
658 TRACE("(%s, %s, %p, %s, %s, %p)\n",
659 debugstr_guid(clsidFilter
),
662 debugstr_guid(pclsidCategory
),
663 debugstr_w(szInstance
),
666 if (prf2
->dwVersion
== 2)
670 else if (prf2
->dwVersion
== 1)
674 /* REGFILTER2 structure is converted from version 1 to 2. Tested on Win2k. */
675 regfilter2
.dwVersion
= 2;
676 regfilter2
.dwMerit
= prf2
->dwMerit
;
677 regfilter2
.u
.s1
.cPins2
= prf2
->u
.s
.cPins
;
678 pregfp2
= (REGFILTERPINS2
*) CoTaskMemAlloc(prf2
->u
.s
.cPins
* sizeof(REGFILTERPINS2
));
679 regfilter2
.u
.s1
.rgPins2
= pregfp2
;
680 for (i
= 0; i
< prf2
->u
.s
.cPins
; i
++)
683 if (prf2
->u
.s
.rgPins
[i
].bRendered
)
684 flags
|= REG_PINFLAG_B_RENDERER
;
685 if (prf2
->u
.s
.rgPins
[i
].bOutput
)
686 flags
|= REG_PINFLAG_B_OUTPUT
;
687 if (prf2
->u
.s
.rgPins
[i
].bZero
)
688 flags
|= REG_PINFLAG_B_ZERO
;
689 if (prf2
->u
.s
.rgPins
[i
].bMany
)
690 flags
|= REG_PINFLAG_B_MANY
;
691 pregfp2
[i
].dwFlags
= flags
;
692 pregfp2
[i
].cInstances
= 1;
693 pregfp2
[i
].nMediaTypes
= prf2
->u
.s
.rgPins
[i
].nMediaTypes
;
694 pregfp2
[i
].lpMediaType
= prf2
->u
.s
.rgPins
[i
].lpMediaType
;
695 pregfp2
[i
].nMediums
= 0;
696 pregfp2
[i
].lpMedium
= NULL
;
697 pregfp2
[i
].clsPinCategory
= NULL
;
702 FIXME("dwVersion other that 1 or 2 not supported at the moment\n");
710 /* MSDN mentions the inexistent CLSID_ActiveMovieFilters GUID.
711 * In fact this is the CLSID_LegacyAmFilterCategory one */
712 pclsidCategory
= &CLSID_LegacyAmFilterCategory
;
714 /* sizeof... will include the null terminator and
715 * the + 1 is for the separator ('\\'). The -1 is
716 * because CHARS_IN_GUID includes the null terminator
718 nameLen
= sizeof(wszDevice
)/sizeof(wszDevice
[0]) + CHARS_IN_GUID
- 1 + 1;
721 nameLen
+= strlenW(szInstance
);
723 nameLen
+= CHARS_IN_GUID
- 1; /* CHARS_IN_GUID includes null terminator */
725 pCurrent
= pwszParseName
= CoTaskMemAlloc(nameLen
*sizeof(WCHAR
));
727 return E_OUTOFMEMORY
;
729 strcpyW(pwszParseName
, wszDevice
);
730 pCurrent
+= strlenW(wszDevice
);
732 hr
= StringFromCLSID(pclsidCategory
, &szClsidTemp
);
736 memcpy(pCurrent
, szClsidTemp
, CHARS_IN_GUID
* sizeof(WCHAR
));
737 pCurrent
+= CHARS_IN_GUID
- 1;
741 strcpyW(pCurrent
+1, szInstance
);
744 CoTaskMemFree(szClsidTemp
);
747 hr
= StringFromCLSID(clsidFilter
, &szClsidTemp
);
749 strcpyW(pCurrent
+1, szClsidTemp
);
754 hr
= CoCreateInstance(&CLSID_CDeviceMoniker
, NULL
, CLSCTX_INPROC
, &IID_IParseDisplayName
, (LPVOID
*)&pParser
);
757 hr
= CreateBindCtx(0, &pBindCtx
);
760 hr
= IParseDisplayName_ParseDisplayName(pParser
, pBindCtx
, pwszParseName
, &ulEaten
, &pMoniker
);
763 IBindCtx_Release(pBindCtx
);
765 IParseDisplayName_Release(pParser
);
768 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
)&pPropBag
);
771 hr
= FM2_WriteFriendlyName(pPropBag
, szName
);
774 hr
= FM2_WriteClsid(pPropBag
, clsidFilter
);
777 hr
= FM2_WriteFilterData(pPropBag
, ®filter2
);
780 IPropertyBag_Release(pPropBag
);
781 CoTaskMemFree(szClsidTemp
);
783 if (SUCCEEDED(hr
) && ppMoniker
)
784 *ppMoniker
= pMoniker
;
786 IMoniker_Release(pMoniker
);
788 CoTaskMemFree(pregfp2
);
790 TRACE("-- returning %x\n", hr
);
795 /* internal helper function */
796 static BOOL
MatchTypes(
799 const REGPINTYPES
* pPinTypes
,
801 const GUID
* pMatchTypes
)
806 if ((nMatchTypes
== 0) && (nPinTypes
> 0))
809 for (j
= 0; j
< nPinTypes
; j
++)
812 for (i
= 0; i
< nMatchTypes
*2; i
+=2)
814 if (((!bExactMatch
&& IsEqualGUID(pPinTypes
[j
].clsMajorType
, &GUID_NULL
)) || IsEqualGUID(&pMatchTypes
[i
], &GUID_NULL
) || IsEqualGUID(pPinTypes
[j
].clsMajorType
, &pMatchTypes
[i
])) &&
815 ((!bExactMatch
&& IsEqualGUID(pPinTypes
[j
].clsMinorType
, &GUID_NULL
)) || IsEqualGUID(&pMatchTypes
[i
+1], &GUID_NULL
) || IsEqualGUID(pPinTypes
[j
].clsMinorType
, &pMatchTypes
[i
+1])))
825 /* internal helper function for qsort of MONIKER_MERIT array */
826 static int mm_compare(const void * left
, const void * right
)
828 const struct MONIKER_MERIT
* mmLeft
= (const struct MONIKER_MERIT
*)left
;
829 const struct MONIKER_MERIT
* mmRight
= (const struct MONIKER_MERIT
*)right
;
831 if (mmLeft
->dwMerit
== mmRight
->dwMerit
)
833 if (mmLeft
->dwMerit
> mmRight
->dwMerit
)
839 * Exact match means whether or not to treat GUID_NULL's in filter data as wild cards
840 * (GUID_NULL's in input to function automatically treated as wild cards)
841 * Input/Output needed means match only on criteria if TRUE (with zero input types
842 * meaning match any input/output pin as long as one exists), otherwise match any
843 * filter that meets the rest of the requirements.
845 static HRESULT WINAPI
FilterMapper2_EnumMatchingFilters(
846 IFilterMapper2
* iface
,
847 IEnumMoniker
**ppEnum
,
853 const GUID
*pInputTypes
,
854 const REGPINMEDIUM
*pMedIn
,
855 const CLSID
*pPinCategoryIn
,
859 const GUID
*pOutputTypes
,
860 const REGPINMEDIUM
*pMedOut
,
861 const CLSID
*pPinCategoryOut
)
863 ICreateDevEnum
* pCreateDevEnum
;
864 IMoniker
* pMonikerCat
;
865 IEnumMoniker
* pEnumCat
;
867 struct Vector monikers
= {NULL
, 0, 0};
869 TRACE("(%p, %x, %s, %x, %s, %d, %p, %p, %p, %s, %s, %p, %p, %p)\n",
872 bExactMatch
? "true" : "false",
874 bInputNeeded
? "true" : "false",
879 bRender
? "true" : "false",
880 bOutputNeeded
? "true" : "false",
887 FIXME("dwFlags = %x not implemented\n", dwFlags
);
892 hr
= CoCreateInstance(&CLSID_SystemDeviceEnum
, NULL
, CLSCTX_INPROC
, &IID_ICreateDevEnum
, (LPVOID
*)&pCreateDevEnum
);
895 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &CLSID_ActiveMovieCategories
, &pEnumCat
, 0);
897 while (IEnumMoniker_Next(pEnumCat
, 1, &pMonikerCat
, NULL
) == S_OK
)
899 IPropertyBag
* pPropBagCat
= NULL
;
901 HRESULT hrSub
; /* this is so that one buggy filter
902 doesn't make the whole lot fail */
906 hrSub
= IMoniker_BindToStorage(pMonikerCat
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBagCat
);
908 if (SUCCEEDED(hrSub
))
909 hrSub
= IPropertyBag_Read(pPropBagCat
, wszMeritName
, &var
, NULL
);
911 if (SUCCEEDED(hrSub
) && (V_UNION(&var
, ulVal
) >= dwMerit
))
914 IEnumMoniker
* pEnum
;
919 if (TRACE_ON(quartz
))
922 V_VT(&temp
) = VT_EMPTY
;
923 IPropertyBag_Read(pPropBagCat
, wszFriendlyName
, &temp
, NULL
);
924 TRACE("Considering category %s\n", debugstr_w(V_UNION(&temp
, bstrVal
)));
928 hrSub
= IPropertyBag_Read(pPropBagCat
, wszClsidName
, &var
, NULL
);
930 if (SUCCEEDED(hrSub
))
931 hrSub
= CLSIDFromString(V_UNION(&var
, bstrVal
), &clsidCat
);
933 if (SUCCEEDED(hrSub
))
934 hrSub
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &clsidCat
, &pEnum
, 0);
938 while (IEnumMoniker_Next(pEnum
, 1, &pMoniker
, NULL
) == S_OK
)
940 IPropertyBag
* pPropBag
= NULL
;
943 BOOL bInputMatch
= !bInputNeeded
;
944 BOOL bOutputMatch
= !bOutputNeeded
;
946 ZeroMemory(&rf2
, sizeof(rf2
));
948 hrSub
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBag
);
950 if (TRACE_ON(quartz
))
953 V_VT(&temp
) = VT_EMPTY
;
954 IPropertyBag_Read(pPropBag
, wszFriendlyName
, &temp
, NULL
);
955 TRACE("Considering filter %s\n", debugstr_w(V_UNION(&temp
, bstrVal
)));
959 if (SUCCEEDED(hrSub
))
960 hrSub
= FM2_ReadFilterData(pPropBag
, &rf2
);
962 /* Logic used for bInputMatch expression:
963 * There exists some pin such that bInputNeeded implies (pin is an input and
964 * (bRender implies pin has render flag) and major/minor types members of
966 * bOutputMatch is similar, but without the "bRender implies ..." part
967 * and substituting variables names containing input for output
970 /* determine whether filter meets requirements */
971 if (SUCCEEDED(hrSub
) && (rf2
.dwMerit
>= dwMerit
))
973 for (i
= 0; (i
< rf2
.u
.s1
.cPins2
) && (!bInputMatch
|| !bOutputMatch
); i
++)
975 const REGFILTERPINS2
* rfp2
= rf2
.u
.s1
.rgPins2
+ i
;
977 bInputMatch
= bInputMatch
|| (!(rfp2
->dwFlags
& REG_PINFLAG_B_OUTPUT
) &&
978 (!bRender
|| (rfp2
->dwFlags
& REG_PINFLAG_B_RENDERER
)) &&
979 MatchTypes(bExactMatch
, rfp2
->nMediaTypes
, rfp2
->lpMediaType
, cInputTypes
, pInputTypes
));
980 bOutputMatch
= bOutputMatch
|| ((rfp2
->dwFlags
& REG_PINFLAG_B_OUTPUT
) &&
981 MatchTypes(bExactMatch
, rfp2
->nMediaTypes
, rfp2
->lpMediaType
, cOutputTypes
, pOutputTypes
));
984 if (bInputMatch
&& bOutputMatch
)
986 struct MONIKER_MERIT mm
= {pMoniker
, rf2
.dwMerit
};
987 IMoniker_AddRef(pMoniker
);
988 add_data(&monikers
, (LPBYTE
)&mm
, sizeof(mm
));
992 FM2_DeleteRegFilter(&rf2
);
994 IPropertyBag_Release(pPropBag
);
995 IMoniker_Release(pMoniker
);
997 IEnumMoniker_Release(pEnum
);
1003 IPropertyBag_Release(pPropBagCat
);
1004 IMoniker_Release(pMonikerCat
);
1009 IMoniker
** ppMoniker
;
1011 ULONG nMonikerCount
= monikers
.current
/ sizeof(struct MONIKER_MERIT
);
1013 /* sort the monikers in descending merit order */
1014 qsort(monikers
.pData
, nMonikerCount
,
1015 sizeof(struct MONIKER_MERIT
),
1018 /* construct an IEnumMoniker interface */
1019 ppMoniker
= CoTaskMemAlloc(nMonikerCount
* sizeof(IMoniker
*));
1020 for (i
= 0; i
< nMonikerCount
; i
++)
1022 /* no need to AddRef here as already AddRef'd above */
1023 ppMoniker
[i
] = ((struct MONIKER_MERIT
*)monikers
.pData
)[i
].pMoniker
;
1025 hr
= EnumMonikerImpl_Create(ppMoniker
, nMonikerCount
, ppEnum
);
1026 CoTaskMemFree(ppMoniker
);
1029 delete_vector(&monikers
);
1030 IEnumMoniker_Release(pEnumCat
);
1031 ICreateDevEnum_Release(pCreateDevEnum
);
1036 static const IFilterMapper2Vtbl fm2vtbl
=
1039 FilterMapper2_QueryInterface
,
1040 FilterMapper2_AddRef
,
1041 FilterMapper2_Release
,
1043 FilterMapper2_CreateCategory
,
1044 FilterMapper2_UnregisterFilter
,
1045 FilterMapper2_RegisterFilter
,
1046 FilterMapper2_EnumMatchingFilters
1049 /*** IUnknown methods ***/
1051 static HRESULT WINAPI
FilterMapper_QueryInterface(IFilterMapper
* iface
, REFIID riid
, LPVOID
*ppv
)
1053 FilterMapper2Impl
*This
= impl_from_IFilterMapper(iface
);
1055 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppv
);
1057 return FilterMapper2_QueryInterface((IFilterMapper2
*)&This
->lpVtbl
, riid
, ppv
);
1060 static ULONG WINAPI
FilterMapper_AddRef(IFilterMapper
* iface
)
1062 FilterMapper2Impl
*This
= impl_from_IFilterMapper(iface
);
1064 return FilterMapper2_AddRef((IFilterMapper2
*)This
);
1067 static ULONG WINAPI
FilterMapper_Release(IFilterMapper
* iface
)
1069 FilterMapper2Impl
*This
= impl_from_IFilterMapper(iface
);
1071 return FilterMapper2_Release((IFilterMapper2
*)This
);
1074 /*** IFilterMapper methods ***/
1076 static HRESULT WINAPI
FilterMapper_EnumMatchingFilters(
1077 IFilterMapper
* iface
,
1078 IEnumRegFilters
**ppEnum
,
1088 FilterMapper2Impl
*This
= impl_from_IFilterMapper(iface
);
1091 IEnumMoniker
* ppEnumMoniker
;
1094 ULONG idx
= 0, nb_mon
= 0;
1095 REGFILTER
* regfilters
;
1098 TRACE("(%p/%p)->(%p, %x, %s, %s, %s, %s, %s, %s, %s) stub!\n",
1102 bInputNeeded
? "true" : "false",
1103 debugstr_guid(&clsInMaj
),
1104 debugstr_guid(&clsInSub
),
1105 bRender
? "true" : "false",
1106 bOutputNeeded
? "true" : "false",
1107 debugstr_guid(&clsOutMaj
),
1108 debugstr_guid(&clsOutSub
));
1110 InputType
[0] = clsInMaj
;
1111 InputType
[1] = clsInSub
;
1112 OutputType
[0] = clsOutMaj
;
1113 OutputType
[1] = clsOutSub
;
1115 hr
= IFilterMapper2_EnumMatchingFilters((IFilterMapper2
*)This
,
1135 while(IEnumMoniker_Next(ppEnumMoniker
, 1, &IMon
, &nb
) == S_OK
)
1137 IMoniker_Release(IMon
);
1144 IEnumMoniker_Release(ppEnumMoniker
);
1145 return IEnumRegFiltersImpl_Construct(NULL
, 0, ppEnum
);
1148 regfilters
= CoTaskMemAlloc(nb_mon
* sizeof(REGFILTER
));
1151 IEnumMoniker_Release(ppEnumMoniker
);
1152 return E_OUTOFMEMORY
;
1155 IEnumMoniker_Reset(ppEnumMoniker
);
1156 while(IEnumMoniker_Next(ppEnumMoniker
, 1, &IMon
, &nb
) == S_OK
)
1158 IPropertyBag
* pPropBagCat
= NULL
;
1165 V_VT(&var
) = VT_BSTR
;
1167 hrSub
= IMoniker_BindToStorage(IMon
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBagCat
);
1169 if (SUCCEEDED(hrSub
))
1170 hrSub
= IPropertyBag_Read(pPropBagCat
, wszClsidName
, &var
, NULL
);
1172 if (SUCCEEDED(hrSub
))
1173 hrSub
= CLSIDFromString(V_UNION(&var
, bstrVal
), &clsid
);
1175 if (SUCCEEDED(hrSub
))
1176 hrSub
= IPropertyBag_Read(pPropBagCat
, wszFriendlyName
, &var
, NULL
);
1178 if (SUCCEEDED(hrSub
))
1180 len
= (strlenW((WCHAR
*)&V_UNION(&var
, bstrVal
))+1) * sizeof(WCHAR
);
1181 if (!(regfilters
[idx
].Name
= CoTaskMemAlloc(len
*2)))
1185 if (SUCCEEDED(hrSub
))
1187 memcpy(regfilters
[idx
].Name
, &V_UNION(&var
, bstrVal
), len
);
1188 regfilters
[idx
].Clsid
= clsid
;
1193 IPropertyBag_Release(pPropBagCat
);
1194 IMoniker_Release(IMon
);
1197 /* In case of release all resources */
1200 for (idx
= 0; idx
< nb_mon
; idx
++)
1201 CoTaskMemFree(regfilters
[idx
].Name
);
1202 CoTaskMemFree(regfilters
);
1203 IEnumMoniker_Release(ppEnumMoniker
);
1207 hr
= IEnumRegFiltersImpl_Construct(regfilters
, nb_mon
, ppEnum
);
1208 CoTaskMemFree(regfilters
);
1209 IEnumMoniker_Release(ppEnumMoniker
);
1215 static HRESULT WINAPI
FilterMapper_RegisterFilter(IFilterMapper
* iface
, CLSID clsid
, LPCWSTR szName
, DWORD dwMerit
)
1218 LPWSTR wszClsid
= NULL
;
1221 WCHAR wszKeyName
[strlenW(wszFilterSlash
) + (CHARS_IN_GUID
-1) + 1];
1223 TRACE("(%p)->(%s, %s, %x)\n", iface
, debugstr_guid(&clsid
), debugstr_w(szName
), dwMerit
);
1225 hr
= StringFromCLSID(&clsid
, &wszClsid
);
1229 strcpyW(wszKeyName
, wszFilterSlash
);
1230 strcatW(wszKeyName
, wszClsid
);
1232 lRet
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
);
1233 hr
= HRESULT_FROM_WIN32(lRet
);
1238 lRet
= RegSetValueExW(hKey
, NULL
, 0, REG_SZ
, (const BYTE
*)szName
, strlenW(szName
) + 1);
1239 hr
= HRESULT_FROM_WIN32(lRet
);
1245 strcpyW(wszKeyName
, wszClsidSlash
);
1246 strcatW(wszKeyName
, wszClsid
);
1248 lRet
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
);
1249 hr
= HRESULT_FROM_WIN32(lRet
);
1254 lRet
= RegSetValueExW(hKey
, wszMeritName
, 0, REG_DWORD
, (LPBYTE
)&dwMerit
, sizeof(dwMerit
));
1255 hr
= HRESULT_FROM_WIN32(lRet
);
1262 static HRESULT WINAPI
FilterMapper_RegisterFilterInstance(IFilterMapper
* iface
, CLSID clsid
, LPCWSTR szName
, CLSID
*MRId
)
1264 TRACE("(%p)->(%s, %s, %p)\n", iface
, debugstr_guid(&clsid
), debugstr_w(szName
), MRId
);
1266 /* Not implemented in Windows (tested on Win2k) */
1271 static HRESULT WINAPI
FilterMapper_RegisterPin(
1272 IFilterMapper
* iface
,
1279 CLSID ConnectsToFilter
,
1280 LPCWSTR ConnectsToPin
)
1284 LPWSTR wszClsid
= NULL
;
1286 HKEY hPinsKey
= NULL
;
1287 WCHAR
* wszPinsKeyName
;
1288 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + (CHARS_IN_GUID
-1) + 1];
1290 TRACE("(%p)->(%s, %s, %d, %d, %d, %d, %s, %s)\n", iface
, debugstr_guid(&Filter
), debugstr_w(szName
), bRendered
,
1291 bOutput
, bZero
, bMany
, debugstr_guid(&ConnectsToFilter
), debugstr_w(ConnectsToPin
));
1293 hr
= StringFromCLSID(&Filter
, &wszClsid
);
1297 strcpyW(wszKeyName
, wszClsidSlash
);
1298 strcatW(wszKeyName
, wszClsid
);
1300 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, KEY_WRITE
, &hKey
);
1301 hr
= HRESULT_FROM_WIN32(lRet
);
1306 wszPinsKeyName
= CoTaskMemAlloc((strlenW(wszPins
) + 1 + strlenW(szName
) + 1) * 2);
1307 if (!wszPinsKeyName
)
1313 strcpyW(wszPinsKeyName
, wszPins
);
1314 strcatW(wszPinsKeyName
, wszSlash
);
1315 strcatW(wszPinsKeyName
, szName
);
1317 lRet
= RegCreateKeyExW(hKey
, wszPinsKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hPinsKey
, NULL
);
1318 hr
= HRESULT_FROM_WIN32(lRet
);
1319 CoTaskMemFree(wszPinsKeyName
);
1324 lRet
= RegSetValueExW(hPinsKey
, wszAllowedMany
, 0, REG_DWORD
, (LPBYTE
)&bMany
, sizeof(bMany
));
1325 hr
= HRESULT_FROM_WIN32(lRet
);
1330 lRet
= RegSetValueExW(hPinsKey
, wszAllowedZero
, 0, REG_DWORD
, (LPBYTE
)&bZero
, sizeof(bZero
));
1331 hr
= HRESULT_FROM_WIN32(lRet
);
1336 lRet
= RegSetValueExW(hPinsKey
, wszDirection
, 0, REG_DWORD
, (LPBYTE
)&bOutput
, sizeof(bOutput
));
1337 hr
= HRESULT_FROM_WIN32(lRet
);
1342 lRet
= RegSetValueExW(hPinsKey
, wszIsRendered
, 0, REG_DWORD
, (LPBYTE
)&bRendered
, sizeof(bRendered
));
1343 hr
= HRESULT_FROM_WIN32(lRet
);
1348 lRet
= RegCreateKeyExW(hPinsKey
, wszTypes
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, NULL
, NULL
);
1349 hr
= HRESULT_FROM_WIN32(lRet
);
1352 CoTaskMemFree(wszClsid
);
1356 CloseHandle(hPinsKey
);
1362 static HRESULT WINAPI
FilterMapper_RegisterPinType(
1363 IFilterMapper
* iface
,
1371 LPWSTR wszClsid
= NULL
;
1372 LPWSTR wszClsidMajorType
= NULL
;
1373 LPWSTR wszClsidSubType
= NULL
;
1375 WCHAR
* wszTypesKey
;
1376 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + (CHARS_IN_GUID
-1) + 1];
1378 TRACE("(%p)->(%s, %s, %s, %s)\n", iface
, debugstr_guid(&clsFilter
), debugstr_w(szName
),
1379 debugstr_guid(&clsMajorType
), debugstr_guid(&clsSubType
));
1381 hr
= StringFromCLSID(&clsFilter
, &wszClsid
);
1385 hr
= StringFromCLSID(&clsMajorType
, &wszClsidMajorType
);
1390 hr
= StringFromCLSID(&clsSubType
, &wszClsidSubType
);
1395 wszTypesKey
= CoTaskMemAlloc((strlenW(wszClsidSlash
) + strlenW(wszClsid
) + strlenW(wszPins
) +
1396 strlenW(szName
) + strlenW(wszTypes
) + 3 + 1) * 2);
1403 strcpyW(wszTypesKey
, wszClsidSlash
);
1404 strcatW(wszTypesKey
, wszClsid
);
1405 strcatW(wszTypesKey
, wszSlash
);
1406 strcatW(wszTypesKey
, wszPins
);
1407 strcatW(wszTypesKey
, wszSlash
);
1408 strcatW(wszTypesKey
, szName
);
1409 strcatW(wszTypesKey
, wszSlash
);
1410 strcatW(wszTypesKey
, wszTypes
);
1412 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszTypesKey
, 0, KEY_WRITE
, &hKey
);
1413 hr
= HRESULT_FROM_WIN32(lRet
);
1414 CoTaskMemFree(wszTypesKey
);
1419 strcpyW(wszKeyName
, wszClsidMajorType
);
1420 strcatW(wszKeyName
, wszSlash
);
1421 strcatW(wszKeyName
, wszClsidSubType
);
1423 lRet
= RegCreateKeyExW(hKey
, wszKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, NULL
, NULL
);
1424 hr
= HRESULT_FROM_WIN32(lRet
);
1428 CoTaskMemFree(wszClsid
);
1429 CoTaskMemFree(wszClsidMajorType
);
1430 CoTaskMemFree(wszClsidSubType
);
1435 static HRESULT WINAPI
FilterMapper_UnregisterFilter(IFilterMapper
* iface
, CLSID Filter
)
1439 LPWSTR wszClsid
= NULL
;
1441 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + (CHARS_IN_GUID
-1) + 1];
1443 TRACE("(%p)->(%s)\n", iface
, debugstr_guid(&Filter
));
1445 hr
= StringFromCLSID(&Filter
, &wszClsid
);
1449 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszFilter
, 0, KEY_WRITE
, &hKey
);
1450 hr
= HRESULT_FROM_WIN32(lRet
);
1455 lRet
= RegDeleteKeyW(hKey
, wszClsid
);
1456 hr
= HRESULT_FROM_WIN32(lRet
);
1462 strcpyW(wszKeyName
, wszClsidSlash
);
1463 strcatW(wszKeyName
, wszClsid
);
1465 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, KEY_WRITE
, &hKey
);
1466 hr
= HRESULT_FROM_WIN32(lRet
);
1471 lRet
= RegDeleteKeyW(hKey
, wszMeritName
);
1472 hr
= HRESULT_FROM_WIN32(lRet
);
1476 CoTaskMemFree(wszClsid
);
1481 static HRESULT WINAPI
FilterMapper_UnregisterFilterInstance(IFilterMapper
* iface
, CLSID MRId
)
1483 TRACE("(%p)->(%s)\n", iface
, debugstr_guid(&MRId
));
1485 /* Not implemented in Windows (tested on Win2k) */
1490 static HRESULT WINAPI
FilterMapper_UnregisterPin(IFilterMapper
* iface
, CLSID Filter
, LPCWSTR Name
)
1494 LPWSTR wszClsid
= NULL
;
1496 WCHAR
* wszPinNameKey
;
1497 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + (CHARS_IN_GUID
-1) + 1];
1499 TRACE("(%p)->(%s, %s)\n", iface
, debugstr_guid(&Filter
), debugstr_w(Name
));
1502 return E_INVALIDARG
;
1504 hr
= StringFromCLSID(&Filter
, &wszClsid
);
1508 strcpyW(wszKeyName
, wszClsidSlash
);
1509 strcatW(wszKeyName
, wszClsid
);
1511 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, KEY_WRITE
, &hKey
);
1512 hr
= HRESULT_FROM_WIN32(lRet
);
1517 wszPinNameKey
= CoTaskMemAlloc((strlenW(wszPins
) + 1 + strlenW(Name
) + 1) * 2);
1524 strcpyW(wszPinNameKey
, wszPins
);
1525 strcatW(wszPinNameKey
, wszSlash
);
1526 strcatW(wszPinNameKey
, Name
);
1528 lRet
= RegDeleteKeyW(hKey
, wszPinNameKey
);
1529 hr
= HRESULT_FROM_WIN32(lRet
);
1530 CoTaskMemFree(wszPinNameKey
);
1533 CoTaskMemFree(wszClsid
);
1540 static const IFilterMapperVtbl fmvtbl
=
1543 FilterMapper_QueryInterface
,
1544 FilterMapper_AddRef
,
1545 FilterMapper_Release
,
1547 FilterMapper_RegisterFilter
,
1548 FilterMapper_RegisterFilterInstance
,
1549 FilterMapper_RegisterPin
,
1550 FilterMapper_RegisterPinType
,
1551 FilterMapper_UnregisterFilter
,
1552 FilterMapper_UnregisterFilterInstance
,
1553 FilterMapper_UnregisterPin
,
1554 FilterMapper_EnumMatchingFilters