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
)
156 CoTaskMemFree(v
->pData
);
161 HRESULT
FilterMapper2_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
163 FilterMapper2Impl
* pFM2impl
;
165 TRACE("(%p, %p)\n", pUnkOuter
, ppObj
);
168 return CLASS_E_NOAGGREGATION
;
170 pFM2impl
= CoTaskMemAlloc(sizeof(*pFM2impl
));
172 return E_OUTOFMEMORY
;
174 pFM2impl
->lpVtbl
= &fm2vtbl
;
175 pFM2impl
->lpVtblFilterMapper
= &fmvtbl
;
176 pFM2impl
->refCount
= 1;
180 TRACE("-- created at %p\n", pFM2impl
);
185 /*** IUnknown methods ***/
187 static HRESULT WINAPI
FilterMapper2_QueryInterface(IFilterMapper2
* iface
, REFIID riid
, LPVOID
*ppv
)
189 FilterMapper2Impl
*This
= (FilterMapper2Impl
*)iface
;
191 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppv
);
195 if (IsEqualIID(riid
, &IID_IUnknown
))
197 else if (IsEqualIID(riid
, &IID_IFilterMapper2
))
199 else if (IsEqualIID(riid
, &IID_IFilterMapper
))
200 *ppv
= &This
->lpVtblFilterMapper
;
204 IUnknown_AddRef((IUnknown
*)*ppv
);
208 FIXME("No interface for %s\n", debugstr_guid(riid
));
209 return E_NOINTERFACE
;
212 static ULONG WINAPI
FilterMapper2_AddRef(IFilterMapper2
* iface
)
214 FilterMapper2Impl
*This
= (FilterMapper2Impl
*)iface
;
215 ULONG refCount
= InterlockedIncrement(&This
->refCount
);
217 TRACE("(%p)->()\n", iface
);
222 static ULONG WINAPI
FilterMapper2_Release(IFilterMapper2
* iface
)
224 FilterMapper2Impl
*This
= (FilterMapper2Impl
*)iface
;
225 ULONG refCount
= InterlockedDecrement(&This
->refCount
);
227 TRACE("(%p)->()\n", iface
);
237 /*** IFilterMapper2 methods ***/
239 static HRESULT WINAPI
FilterMapper2_CreateCategory(
240 IFilterMapper2
* iface
,
241 REFCLSID clsidCategory
,
242 DWORD dwCategoryMerit
,
243 LPCWSTR szDescription
)
245 LPWSTR wClsidAMCat
= NULL
;
246 LPWSTR wClsidCategory
= NULL
;
247 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + strlenW(wszSlashInstance
) + (CHARS_IN_GUID
-1) * 2 + 1];
252 TRACE("(%s, %lx, %s)\n", debugstr_guid(clsidCategory
), dwCategoryMerit
, debugstr_w(szDescription
));
254 hr
= StringFromCLSID(&CLSID_ActiveMovieCategories
, &wClsidAMCat
);
258 hr
= StringFromCLSID(clsidCategory
, &wClsidCategory
);
263 strcpyW(wszKeyName
, wszClsidSlash
);
264 strcatW(wszKeyName
, wClsidAMCat
);
265 strcatW(wszKeyName
, wszSlashInstance
);
266 strcatW(wszKeyName
, wClsidCategory
);
268 lRet
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
);
269 hr
= HRESULT_FROM_WIN32(lRet
);
274 lRet
= RegSetValueExW(hKey
, wszFriendlyName
, 0, REG_SZ
, (const BYTE
*)szDescription
, (strlenW(szDescription
) + 1) * sizeof(WCHAR
));
275 hr
= HRESULT_FROM_WIN32(lRet
);
280 lRet
= RegSetValueExW(hKey
, wszClsidName
, 0, REG_SZ
, (LPBYTE
)wClsidCategory
, (strlenW(wClsidCategory
) + 1) * sizeof(WCHAR
));
281 hr
= HRESULT_FROM_WIN32(lRet
);
286 lRet
= RegSetValueExW(hKey
, wszMeritName
, 0, REG_DWORD
, (LPBYTE
)&dwCategoryMerit
, sizeof(dwCategoryMerit
));
287 hr
= HRESULT_FROM_WIN32(lRet
);
293 CoTaskMemFree(wClsidCategory
);
295 CoTaskMemFree(wClsidAMCat
);
300 static HRESULT WINAPI
FilterMapper2_UnregisterFilter(
301 IFilterMapper2
* iface
,
302 const CLSID
*pclsidCategory
,
303 const OLECHAR
*szInstance
,
306 WCHAR wszKeyName
[MAX_PATH
];
307 LPWSTR wClsidCategory
= NULL
;
308 LPWSTR wFilter
= NULL
;
311 TRACE("(%p, %s, %s)\n", pclsidCategory
, debugstr_w(szInstance
), debugstr_guid(Filter
));
314 pclsidCategory
= &CLSID_LegacyAmFilterCategory
;
316 hr
= StringFromCLSID(pclsidCategory
, &wClsidCategory
);
320 strcpyW(wszKeyName
, wszClsidSlash
);
321 strcatW(wszKeyName
, wClsidCategory
);
322 strcatW(wszKeyName
, wszSlashInstance
);
324 strcatW(wszKeyName
, szInstance
);
327 hr
= StringFromCLSID(Filter
, &wFilter
);
329 strcatW(wszKeyName
, wFilter
);
335 LONG lRet
= RegDeleteKeyW(HKEY_CLASSES_ROOT
, wszKeyName
);
336 hr
= HRESULT_FROM_WIN32(lRet
);
340 CoTaskMemFree(wClsidCategory
);
342 CoTaskMemFree(wFilter
);
347 static HRESULT
FM2_WriteFriendlyName(IPropertyBag
* pPropBag
, LPCWSTR szName
)
351 V_VT(&var
) = VT_BSTR
;
352 V_UNION(&var
, bstrVal
) = (BSTR
)szName
;
354 return IPropertyBag_Write(pPropBag
, wszFriendlyName
, &var
);
357 static HRESULT
FM2_WriteClsid(IPropertyBag
* pPropBag
, REFCLSID clsid
)
359 LPWSTR wszClsid
= NULL
;
363 hr
= StringFromCLSID(clsid
, &wszClsid
);
367 V_VT(&var
) = VT_BSTR
;
368 V_UNION(&var
, bstrVal
) = wszClsid
;
369 hr
= IPropertyBag_Write(pPropBag
, wszClsidName
, &var
);
372 CoTaskMemFree(wszClsid
);
376 static HRESULT
FM2_WriteFilterData(IPropertyBag
* pPropBag
, const REGFILTER2
* prf2
)
379 int size
= sizeof(struct REG_RF
);
381 struct Vector mainStore
= {NULL
, 0, 0};
382 struct Vector clsidStore
= {NULL
, 0, 0};
385 SAFEARRAYBOUND saBound
;
388 rrf
.dwVersion
= prf2
->dwVersion
;
389 rrf
.dwMerit
= prf2
->dwMerit
;
390 rrf
.dwPins
= prf2
->u
.s1
.cPins2
;
393 add_data(&mainStore
, (LPBYTE
)&rrf
, sizeof(rrf
));
395 for (i
= 0; i
< prf2
->u
.s1
.cPins2
; i
++)
397 size
+= sizeof(struct REG_RFP
);
398 if (prf2
->u
.s1
.rgPins2
[i
].clsPinCategory
)
399 size
+= sizeof(DWORD
);
400 size
+= prf2
->u
.s1
.rgPins2
[i
].nMediaTypes
* sizeof(struct REG_TYPE
);
401 size
+= prf2
->u
.s1
.rgPins2
[i
].nMediums
* sizeof(DWORD
);
404 for (i
= 0; i
< prf2
->u
.s1
.cPins2
; i
++)
407 REGFILTERPINS2 rgPin2
= prf2
->u
.s1
.rgPins2
[i
];
410 rrfp
.signature
[0] = '0';
411 rrfp
.signature
[1] = 'p';
412 rrfp
.signature
[2] = 'i';
413 rrfp
.signature
[3] = '3';
414 rrfp
.signature
[0] += i
;
415 rrfp
.dwFlags
= rgPin2
.dwFlags
;
416 rrfp
.dwInstances
= rgPin2
.cInstances
;
417 rrfp
.dwMediaTypes
= rgPin2
.nMediaTypes
;
418 rrfp
.dwMediums
= rgPin2
.nMediums
;
419 rrfp
.bCategory
= rgPin2
.clsPinCategory
? 1 : 0;
421 add_data(&mainStore
, (LPBYTE
)&rrfp
, sizeof(rrfp
));
424 DWORD index
= find_data(&clsidStore
, (const BYTE
*)rgPin2
.clsPinCategory
, sizeof(CLSID
));
426 index
= add_data(&clsidStore
, (const BYTE
*)rgPin2
.clsPinCategory
, sizeof(CLSID
));
429 add_data(&mainStore
, (LPBYTE
)&index
, sizeof(index
));
432 for (j
= 0; j
< rgPin2
.nMediaTypes
; j
++)
435 rt
.signature
[0] = '0';
436 rt
.signature
[1] = 't';
437 rt
.signature
[2] = 'y';
438 rt
.signature
[3] = '3';
439 rt
.signature
[0] += j
;
442 rt
.dwOffsetMajor
= find_data(&clsidStore
, (const BYTE
*)rgPin2
.lpMediaType
[j
].clsMajorType
, sizeof(CLSID
));
443 if (rt
.dwOffsetMajor
== -1)
444 rt
.dwOffsetMajor
= add_data(&clsidStore
, (const BYTE
*)rgPin2
.lpMediaType
[j
].clsMajorType
, sizeof(CLSID
));
445 rt
.dwOffsetMajor
+= size
;
446 rt
.dwOffsetMinor
= find_data(&clsidStore
, (const BYTE
*)rgPin2
.lpMediaType
[j
].clsMinorType
, sizeof(CLSID
));
447 if (rt
.dwOffsetMinor
== -1)
448 rt
.dwOffsetMinor
= add_data(&clsidStore
, (const BYTE
*)rgPin2
.lpMediaType
[j
].clsMinorType
, sizeof(CLSID
));
449 rt
.dwOffsetMinor
+= size
;
451 add_data(&mainStore
, (LPBYTE
)&rt
, sizeof(rt
));
454 for (j
= 0; j
< rgPin2
.nMediums
; j
++)
456 DWORD index
= find_data(&clsidStore
, (const BYTE
*)(rgPin2
.lpMedium
+ j
), sizeof(REGPINMEDIUM
));
458 index
= add_data(&clsidStore
, (const BYTE
*)(rgPin2
.lpMedium
+ j
), sizeof(REGPINMEDIUM
));
461 add_data(&mainStore
, (LPBYTE
)&index
, sizeof(index
));
466 saBound
.cElements
= mainStore
.current
+ clsidStore
.current
;
467 psa
= SafeArrayCreate(VT_UI1
, 1, &saBound
);
470 ERR("Couldn't create SAFEARRAY\n");
477 hr
= SafeArrayAccessData(psa
, (LPVOID
*)&pbSAData
);
480 memcpy(pbSAData
, mainStore
.pData
, mainStore
.current
);
481 memcpy(pbSAData
+ mainStore
.current
, clsidStore
.pData
, clsidStore
.current
);
482 hr
= SafeArrayUnaccessData(psa
);
486 V_VT(&var
) = VT_ARRAY
| VT_UI1
;
487 V_UNION(&var
, parray
) = psa
;
490 hr
= IPropertyBag_Write(pPropBag
, wszFilterDataName
, &var
);
493 SafeArrayDestroy(psa
);
495 delete_vector(&mainStore
);
496 delete_vector(&clsidStore
);
500 static HRESULT
FM2_ReadFilterData(IPropertyBag
* pPropBag
, REGFILTER2
* prf2
)
505 struct REG_RF
* prrf
;
508 REGFILTERPINS2
* rgPins2
;
511 V_VT(&var
) = VT_ARRAY
| VT_UI1
;
513 hr
= IPropertyBag_Read(pPropBag
, wszFilterDataName
, &var
, NULL
);
516 hr
= SafeArrayAccessData(V_UNION(&var
, parray
), (LPVOID
*)&pData
);
520 prrf
= (struct REG_RF
*)pData
;
523 if (prrf
->dwVersion
!= 2)
525 FIXME("Filter registry version %ld not supported\n", prrf
->dwVersion
);
526 ZeroMemory(prf2
, sizeof(*prf2
));
533 TRACE("version = %ld, merit = %lx, #pins = %ld, unused = %lx\n",
534 prrf
->dwVersion
, prrf
->dwMerit
, prrf
->dwPins
, prrf
->dwUnused
);
536 prf2
->dwVersion
= prrf
->dwVersion
;
537 prf2
->dwMerit
= prrf
->dwMerit
;
538 prf2
->u
.s1
.cPins2
= prrf
->dwPins
;
539 rgPins2
= CoTaskMemAlloc(prrf
->dwPins
* sizeof(*rgPins2
));
540 prf2
->u
.s1
.rgPins2
= rgPins2
;
541 pCurrent
+= sizeof(struct REG_RF
);
543 for (i
= 0; i
< prrf
->dwPins
; i
++)
545 struct REG_RFP
* prrfp
= (struct REG_RFP
*)pCurrent
;
546 REGPINTYPES
* lpMediaType
;
547 REGPINMEDIUM
* lpMedium
;
550 /* FIXME: check signature */
552 TRACE("\tsignature = %s\n", debugstr_an((const char*)prrfp
->signature
, 4));
554 TRACE("\tpin[%ld]: flags = %lx, instances = %ld, media types = %ld, mediums = %ld\n",
555 i
, prrfp
->dwFlags
, prrfp
->dwInstances
, prrfp
->dwMediaTypes
, prrfp
->dwMediums
);
557 rgPins2
[i
].dwFlags
= prrfp
->dwFlags
;
558 rgPins2
[i
].cInstances
= prrfp
->dwInstances
;
559 rgPins2
[i
].nMediaTypes
= prrfp
->dwMediaTypes
;
560 rgPins2
[i
].nMediums
= prrfp
->dwMediums
;
561 pCurrent
+= sizeof(struct REG_RFP
);
562 if (prrfp
->bCategory
)
564 CLSID
* clsCat
= CoTaskMemAlloc(sizeof(CLSID
));
565 memcpy(clsCat
, pData
+ *(DWORD
*)(pCurrent
), sizeof(CLSID
));
566 pCurrent
+= sizeof(DWORD
);
567 rgPins2
[i
].clsPinCategory
= clsCat
;
570 rgPins2
[i
].clsPinCategory
= NULL
;
572 if (rgPins2
[i
].nMediaTypes
> 0)
573 lpMediaType
= CoTaskMemAlloc(rgPins2
[i
].nMediaTypes
* sizeof(*lpMediaType
));
577 rgPins2
[i
].lpMediaType
= lpMediaType
;
579 for (j
= 0; j
< rgPins2
[i
].nMediaTypes
; j
++)
581 struct REG_TYPE
* prt
= (struct REG_TYPE
*)pCurrent
;
582 CLSID
* clsMajor
= CoTaskMemAlloc(sizeof(CLSID
));
583 CLSID
* clsMinor
= CoTaskMemAlloc(sizeof(CLSID
));
585 /* FIXME: check signature */
586 TRACE("\t\tsignature = %s\n", debugstr_an((const char*)prt
->signature
, 4));
588 memcpy(clsMajor
, pData
+ prt
->dwOffsetMajor
, sizeof(CLSID
));
589 memcpy(clsMinor
, pData
+ prt
->dwOffsetMinor
, sizeof(CLSID
));
591 lpMediaType
[j
].clsMajorType
= clsMajor
;
592 lpMediaType
[j
].clsMinorType
= clsMinor
;
594 pCurrent
+= sizeof(*prt
);
597 if (rgPins2
[i
].nMediums
> 0)
598 lpMedium
= CoTaskMemAlloc(rgPins2
[i
].nMediums
* sizeof(*lpMedium
));
602 rgPins2
[i
].lpMedium
= lpMedium
;
604 for (j
= 0; j
< rgPins2
[i
].nMediums
; j
++)
606 DWORD dwOffset
= *(DWORD
*)pCurrent
;
608 memcpy(lpMedium
+ j
, pData
+ dwOffset
, sizeof(REGPINMEDIUM
));
610 pCurrent
+= sizeof(dwOffset
);
617 SafeArrayUnaccessData(V_UNION(&var
, parray
));
624 static void FM2_DeleteRegFilter(REGFILTER2
* prf2
)
627 for (i
= 0; i
< prf2
->u
.s1
.cPins2
; i
++)
630 if (prf2
->u
.s1
.rgPins2
[i
].clsPinCategory
)
631 CoTaskMemFree((LPVOID
)prf2
->u
.s1
.rgPins2
[i
].clsPinCategory
);
633 for (j
= 0; j
< prf2
->u
.s1
.rgPins2
[i
].nMediaTypes
; j
++)
635 CoTaskMemFree((LPVOID
)prf2
->u
.s1
.rgPins2
[i
].lpMediaType
[j
].clsMajorType
);
636 CoTaskMemFree((LPVOID
)prf2
->u
.s1
.rgPins2
[i
].lpMediaType
[j
].clsMinorType
);
638 CoTaskMemFree((LPVOID
)prf2
->u
.s1
.rgPins2
[i
].lpMedium
);
642 static HRESULT WINAPI
FilterMapper2_RegisterFilter(
643 IFilterMapper2
* iface
,
644 REFCLSID clsidFilter
,
646 IMoniker
**ppMoniker
,
647 const CLSID
*pclsidCategory
,
648 const OLECHAR
*szInstance
,
649 const REGFILTER2
*prf2
)
651 IParseDisplayName
* pParser
= NULL
;
652 IBindCtx
* pBindCtx
= NULL
;
653 IMoniker
* pMoniker
= NULL
;
654 IPropertyBag
* pPropBag
= NULL
;
656 LPWSTR pwszParseName
= NULL
;
658 static const WCHAR wszDevice
[] = {'@','d','e','v','i','c','e',':','s','w',':',0};
661 LPWSTR szClsidTemp
= NULL
;
662 REGFILTER2 regfilter2
;
663 REGFILTERPINS2
* pregfp2
= NULL
;
665 TRACE("(%s, %s, %p, %s, %s, %p)\n",
666 debugstr_guid(clsidFilter
),
669 debugstr_guid(pclsidCategory
),
670 debugstr_w(szInstance
),
673 if (prf2
->dwVersion
== 2)
677 else if (prf2
->dwVersion
== 1)
681 /* REGFILTER2 structure is converted from version 1 to 2. Tested on Win2k. */
682 regfilter2
.dwVersion
= 2;
683 regfilter2
.dwMerit
= prf2
->dwMerit
;
684 regfilter2
.u
.s1
.cPins2
= prf2
->u
.s
.cPins
;
685 pregfp2
= (REGFILTERPINS2
*) CoTaskMemAlloc(prf2
->u
.s
.cPins
* sizeof(REGFILTERPINS2
));
686 regfilter2
.u
.s1
.rgPins2
= pregfp2
;
687 for (i
= 0; i
< prf2
->u
.s
.cPins
; i
++)
690 if (prf2
->u
.s
.rgPins
[i
].bRendered
)
691 flags
|= REG_PINFLAG_B_RENDERER
;
692 if (prf2
->u
.s
.rgPins
[i
].bOutput
)
693 flags
|= REG_PINFLAG_B_OUTPUT
;
694 if (prf2
->u
.s
.rgPins
[i
].bZero
)
695 flags
|= REG_PINFLAG_B_ZERO
;
696 if (prf2
->u
.s
.rgPins
[i
].bMany
)
697 flags
|= REG_PINFLAG_B_MANY
;
698 pregfp2
[i
].dwFlags
= flags
;
699 pregfp2
[i
].cInstances
= 1;
700 pregfp2
[i
].nMediaTypes
= prf2
->u
.s
.rgPins
[i
].nMediaTypes
;
701 pregfp2
[i
].lpMediaType
= prf2
->u
.s
.rgPins
[i
].lpMediaType
;
702 pregfp2
[i
].nMediums
= 0;
703 pregfp2
[i
].lpMedium
= NULL
;
704 pregfp2
[i
].clsPinCategory
= NULL
;
709 FIXME("dwVersion other that 1 or 2 not supported at the moment\n");
717 /* MSDN mentions the inexistent CLSID_ActiveMovieFilters GUID.
718 * In fact this is the CLSID_LegacyAmFilterCategory one */
719 pclsidCategory
= &CLSID_LegacyAmFilterCategory
;
721 /* sizeof... will include the null terminator and
722 * the + 1 is for the separator ('\\'). The -1 is
723 * because CHARS_IN_GUID includes the null terminator
725 nameLen
= sizeof(wszDevice
)/sizeof(wszDevice
[0]) + CHARS_IN_GUID
- 1 + 1;
728 nameLen
+= strlenW(szInstance
);
730 nameLen
+= CHARS_IN_GUID
- 1; /* CHARS_IN_GUID includes null terminator */
732 pCurrent
= pwszParseName
= CoTaskMemAlloc(nameLen
*sizeof(WCHAR
));
734 return E_OUTOFMEMORY
;
736 strcpyW(pwszParseName
, wszDevice
);
737 pCurrent
+= strlenW(wszDevice
);
739 hr
= StringFromCLSID(pclsidCategory
, &szClsidTemp
);
743 memcpy(pCurrent
, szClsidTemp
, CHARS_IN_GUID
* sizeof(WCHAR
));
744 pCurrent
+= CHARS_IN_GUID
- 1;
748 strcpyW(pCurrent
+1, szInstance
);
753 CoTaskMemFree(szClsidTemp
);
756 hr
= StringFromCLSID(clsidFilter
, &szClsidTemp
);
758 strcpyW(pCurrent
+1, szClsidTemp
);
763 hr
= CoCreateInstance(&CLSID_CDeviceMoniker
, NULL
, CLSCTX_INPROC
, &IID_IParseDisplayName
, (LPVOID
*)&pParser
);
766 hr
= CreateBindCtx(0, &pBindCtx
);
769 hr
= IParseDisplayName_ParseDisplayName(pParser
, pBindCtx
, pwszParseName
, &ulEaten
, &pMoniker
);
772 IBindCtx_Release(pBindCtx
);
774 IParseDisplayName_Release(pParser
);
777 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
)&pPropBag
);
780 hr
= FM2_WriteFriendlyName(pPropBag
, szName
);
783 hr
= FM2_WriteClsid(pPropBag
, clsidFilter
);
786 hr
= FM2_WriteFilterData(pPropBag
, ®filter2
);
789 IPropertyBag_Release(pPropBag
);
791 CoTaskMemFree(szClsidTemp
);
793 if (SUCCEEDED(hr
) && ppMoniker
)
794 *ppMoniker
= pMoniker
;
796 IMoniker_Release(pMoniker
);
799 CoTaskMemFree(pregfp2
);
801 TRACE("-- returning %lx\n", hr
);
806 /* internal helper function */
807 static BOOL
MatchTypes(
810 const REGPINTYPES
* pPinTypes
,
812 const GUID
* pMatchTypes
)
817 if ((nMatchTypes
== 0) && (nPinTypes
> 0))
820 for (j
= 0; j
< nPinTypes
; j
++)
823 for (i
= 0; i
< nMatchTypes
*2; i
+=2)
825 if (((!bExactMatch
&& IsEqualGUID(pPinTypes
[j
].clsMajorType
, &GUID_NULL
)) || IsEqualGUID(&pMatchTypes
[i
], &GUID_NULL
) || IsEqualGUID(pPinTypes
[j
].clsMajorType
, &pMatchTypes
[i
])) &&
826 ((!bExactMatch
&& IsEqualGUID(pPinTypes
[j
].clsMinorType
, &GUID_NULL
)) || IsEqualGUID(&pMatchTypes
[i
+1], &GUID_NULL
) || IsEqualGUID(pPinTypes
[j
].clsMinorType
, &pMatchTypes
[i
+1])))
836 /* internal helper function for qsort of MONIKER_MERIT array */
837 static int mm_compare(const void * left
, const void * right
)
839 const struct MONIKER_MERIT
* mmLeft
= (const struct MONIKER_MERIT
*)left
;
840 const struct MONIKER_MERIT
* mmRight
= (const struct MONIKER_MERIT
*)right
;
842 if (mmLeft
->dwMerit
== mmRight
->dwMerit
)
844 if (mmLeft
->dwMerit
> mmRight
->dwMerit
)
850 * Exact match means whether or not to treat GUID_NULL's in filter data as wild cards
851 * (GUID_NULL's in input to function automatically treated as wild cards)
852 * Input/Output needed means match only on criteria if TRUE (with zero input types
853 * meaning match any input/output pin as long as one exists), otherwise match any
854 * filter that meets the rest of the requirements.
856 static HRESULT WINAPI
FilterMapper2_EnumMatchingFilters(
857 IFilterMapper2
* iface
,
858 IEnumMoniker
**ppEnum
,
864 const GUID
*pInputTypes
,
865 const REGPINMEDIUM
*pMedIn
,
866 const CLSID
*pPinCategoryIn
,
870 const GUID
*pOutputTypes
,
871 const REGPINMEDIUM
*pMedOut
,
872 const CLSID
*pPinCategoryOut
)
874 ICreateDevEnum
* pCreateDevEnum
;
875 IMoniker
* pMonikerCat
;
876 IEnumMoniker
* pEnumCat
;
878 struct Vector monikers
= {NULL
, 0, 0};
880 TRACE("(%p, %lx, %s, %lx, %s, %ld, %p, %p, %p, %s, %s, %p, %p, %p)\n",
883 bExactMatch
? "true" : "false",
885 bInputNeeded
? "true" : "false",
890 bRender
? "true" : "false",
891 bOutputNeeded
? "true" : "false",
898 FIXME("dwFlags = %lx not implemented\n", dwFlags
);
903 hr
= CoCreateInstance(&CLSID_SystemDeviceEnum
, NULL
, CLSCTX_INPROC
, &IID_ICreateDevEnum
, (LPVOID
*)&pCreateDevEnum
);
906 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &CLSID_ActiveMovieCategories
, &pEnumCat
, 0);
908 while (IEnumMoniker_Next(pEnumCat
, 1, &pMonikerCat
, NULL
) == S_OK
)
910 IPropertyBag
* pPropBagCat
= NULL
;
912 HRESULT hrSub
; /* this is so that one buggy filter
913 doesn't make the whole lot fail */
917 hrSub
= IMoniker_BindToStorage(pMonikerCat
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBagCat
);
919 if (SUCCEEDED(hrSub
))
920 hrSub
= IPropertyBag_Read(pPropBagCat
, wszMeritName
, &var
, NULL
);
922 if (SUCCEEDED(hrSub
) && (V_UNION(&var
, ulVal
) >= dwMerit
))
925 IEnumMoniker
* pEnum
;
930 if (TRACE_ON(quartz
))
933 V_VT(&temp
) = VT_EMPTY
;
934 IPropertyBag_Read(pPropBagCat
, wszFriendlyName
, &temp
, NULL
);
935 TRACE("Considering category %s\n", debugstr_w(V_UNION(&temp
, bstrVal
)));
939 hrSub
= IPropertyBag_Read(pPropBagCat
, wszClsidName
, &var
, NULL
);
941 if (SUCCEEDED(hrSub
))
942 hrSub
= CLSIDFromString(V_UNION(&var
, bstrVal
), &clsidCat
);
944 if (SUCCEEDED(hrSub
))
945 hrSub
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &clsidCat
, &pEnum
, 0);
949 while (IEnumMoniker_Next(pEnum
, 1, &pMoniker
, NULL
) == S_OK
)
951 IPropertyBag
* pPropBag
= NULL
;
954 BOOL bInputMatch
= !bInputNeeded
;
955 BOOL bOutputMatch
= !bOutputNeeded
;
957 ZeroMemory(&rf2
, sizeof(rf2
));
959 hrSub
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBag
);
961 if (TRACE_ON(quartz
))
964 V_VT(&temp
) = VT_EMPTY
;
965 IPropertyBag_Read(pPropBag
, wszFriendlyName
, &temp
, NULL
);
966 TRACE("Considering filter %s\n", debugstr_w(V_UNION(&temp
, bstrVal
)));
970 if (SUCCEEDED(hrSub
))
971 hrSub
= FM2_ReadFilterData(pPropBag
, &rf2
);
973 /* Logic used for bInputMatch expression:
974 * There exists some pin such that bInputNeeded implies (pin is an input and
975 * (bRender implies pin has render flag) and major/minor types members of
977 * bOutputMatch is similar, but without the "bRender implies ..." part
978 * and substituting variables names containing input for output
981 /* determine whether filter meets requirements */
982 if (SUCCEEDED(hrSub
) && (rf2
.dwMerit
>= dwMerit
))
984 for (i
= 0; (i
< rf2
.u
.s1
.cPins2
) && (!bInputMatch
|| !bOutputMatch
); i
++)
986 const REGFILTERPINS2
* rfp2
= rf2
.u
.s1
.rgPins2
+ i
;
988 bInputMatch
= bInputMatch
|| (!(rfp2
->dwFlags
& REG_PINFLAG_B_OUTPUT
) &&
989 (!bRender
|| (rfp2
->dwFlags
& REG_PINFLAG_B_RENDERER
)) &&
990 MatchTypes(bExactMatch
, rfp2
->nMediaTypes
, rfp2
->lpMediaType
, cInputTypes
, pInputTypes
));
991 bOutputMatch
= bOutputMatch
|| ((rfp2
->dwFlags
& REG_PINFLAG_B_OUTPUT
) &&
992 MatchTypes(bExactMatch
, rfp2
->nMediaTypes
, rfp2
->lpMediaType
, cOutputTypes
, pOutputTypes
));
995 if (bInputMatch
&& bOutputMatch
)
997 struct MONIKER_MERIT mm
= {pMoniker
, rf2
.dwMerit
};
998 IMoniker_AddRef(pMoniker
);
999 add_data(&monikers
, (LPBYTE
)&mm
, sizeof(mm
));
1003 FM2_DeleteRegFilter(&rf2
);
1005 IPropertyBag_Release(pPropBag
);
1006 IMoniker_Release(pMoniker
);
1008 IEnumMoniker_Release(pEnum
);
1014 IPropertyBag_Release(pPropBagCat
);
1015 IMoniker_Release(pMonikerCat
);
1020 IMoniker
** ppMoniker
;
1022 ULONG nMonikerCount
= monikers
.current
/ sizeof(struct MONIKER_MERIT
);
1024 /* sort the monikers in descending merit order */
1025 qsort(monikers
.pData
, nMonikerCount
,
1026 sizeof(struct MONIKER_MERIT
),
1029 /* construct an IEnumMoniker interface */
1030 ppMoniker
= CoTaskMemAlloc(nMonikerCount
* sizeof(IMoniker
*));
1031 for (i
= 0; i
< nMonikerCount
; i
++)
1033 /* no need to AddRef here as already AddRef'd above */
1034 ppMoniker
[i
] = ((struct MONIKER_MERIT
*)monikers
.pData
)[i
].pMoniker
;
1036 hr
= EnumMonikerImpl_Create(ppMoniker
, nMonikerCount
, ppEnum
);
1037 CoTaskMemFree(ppMoniker
);
1040 delete_vector(&monikers
);
1041 IEnumMoniker_Release(pEnumCat
);
1042 ICreateDevEnum_Release(pCreateDevEnum
);
1047 static const IFilterMapper2Vtbl fm2vtbl
=
1050 FilterMapper2_QueryInterface
,
1051 FilterMapper2_AddRef
,
1052 FilterMapper2_Release
,
1054 FilterMapper2_CreateCategory
,
1055 FilterMapper2_UnregisterFilter
,
1056 FilterMapper2_RegisterFilter
,
1057 FilterMapper2_EnumMatchingFilters
1060 /*** IUnknown methods ***/
1062 static HRESULT WINAPI
FilterMapper_QueryInterface(IFilterMapper
* iface
, REFIID riid
, LPVOID
*ppv
)
1064 FilterMapper2Impl
*This
= impl_from_IFilterMapper(iface
);
1066 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppv
);
1068 return FilterMapper2_QueryInterface((IFilterMapper2
*)&This
->lpVtbl
, riid
, ppv
);
1071 static ULONG WINAPI
FilterMapper_AddRef(IFilterMapper
* iface
)
1073 FilterMapper2Impl
*This
= impl_from_IFilterMapper(iface
);
1075 return FilterMapper2_AddRef((IFilterMapper2
*)This
);
1078 static ULONG WINAPI
FilterMapper_Release(IFilterMapper
* iface
)
1080 FilterMapper2Impl
*This
= impl_from_IFilterMapper(iface
);
1082 return FilterMapper2_Release((IFilterMapper2
*)This
);
1085 /*** IFilterMapper methods ***/
1087 static HRESULT WINAPI
FilterMapper_EnumMatchingFilters(
1088 IFilterMapper
* iface
,
1089 IEnumRegFilters
**ppEnum
,
1099 FilterMapper2Impl
*This
= impl_from_IFilterMapper(iface
);
1102 IEnumMoniker
* ppEnumMoniker
;
1105 ULONG idx
= 0, nb_mon
= 0;
1106 REGFILTER
* regfilters
;
1109 TRACE("(%p/%p)->(%p, %lx, %s, %s, %s, %s, %s, %s, %s) stub!\n",
1113 bInputNeeded
? "true" : "false",
1114 debugstr_guid(&clsInMaj
),
1115 debugstr_guid(&clsInSub
),
1116 bRender
? "true" : "false",
1117 bOutputNeeded
? "true" : "false",
1118 debugstr_guid(&clsOutMaj
),
1119 debugstr_guid(&clsOutSub
));
1121 InputType
[0] = clsInMaj
;
1122 InputType
[1] = clsInSub
;
1123 OutputType
[0] = clsOutMaj
;
1124 OutputType
[1] = clsOutSub
;
1126 hr
= IFilterMapper2_EnumMatchingFilters((IFilterMapper2
*)This
,
1146 while(IEnumMoniker_Next(ppEnumMoniker
, 1, &IMon
, &nb
) == S_OK
)
1148 IMoniker_Release(IMon
);
1155 IEnumMoniker_Release(ppEnumMoniker
);
1156 return IEnumRegFiltersImpl_Construct(NULL
, 0, ppEnum
);
1159 regfilters
= CoTaskMemAlloc(nb_mon
* sizeof(REGFILTER
));
1162 IEnumMoniker_Release(ppEnumMoniker
);
1163 return E_OUTOFMEMORY
;
1166 IEnumMoniker_Reset(ppEnumMoniker
);
1167 while(IEnumMoniker_Next(ppEnumMoniker
, 1, &IMon
, &nb
) == S_OK
)
1169 IPropertyBag
* pPropBagCat
= NULL
;
1176 V_VT(&var
) = VT_BSTR
;
1178 hrSub
= IMoniker_BindToStorage(IMon
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBagCat
);
1180 if (SUCCEEDED(hrSub
))
1181 hrSub
= IPropertyBag_Read(pPropBagCat
, wszClsidName
, &var
, NULL
);
1183 if (SUCCEEDED(hrSub
))
1184 hrSub
= CLSIDFromString(V_UNION(&var
, bstrVal
), &clsid
);
1186 if (SUCCEEDED(hrSub
))
1187 hrSub
= IPropertyBag_Read(pPropBagCat
, wszFriendlyName
, &var
, NULL
);
1189 if (SUCCEEDED(hrSub
))
1191 len
= (strlenW((WCHAR
*)&V_UNION(&var
, bstrVal
))+1) * sizeof(WCHAR
);
1192 if (!(regfilters
[idx
].Name
= CoTaskMemAlloc(len
*2)))
1196 if (SUCCEEDED(hrSub
))
1198 memcpy(regfilters
[idx
].Name
, &V_UNION(&var
, bstrVal
), len
);
1199 regfilters
[idx
].Clsid
= clsid
;
1204 IPropertyBag_Release(pPropBagCat
);
1205 IMoniker_Release(IMon
);
1208 /* In case of release all resources */
1211 for (idx
= 0; idx
< nb_mon
; idx
++)
1212 CoTaskMemFree(regfilters
[idx
].Name
);
1213 CoTaskMemFree(regfilters
);
1214 IEnumMoniker_Release(ppEnumMoniker
);
1218 hr
= IEnumRegFiltersImpl_Construct(regfilters
, nb_mon
, ppEnum
);
1219 CoTaskMemFree(regfilters
);
1220 IEnumMoniker_Release(ppEnumMoniker
);
1226 static HRESULT WINAPI
FilterMapper_RegisterFilter(IFilterMapper
* iface
, CLSID clsid
, LPCWSTR szName
, DWORD dwMerit
)
1229 LPWSTR wszClsid
= NULL
;
1232 WCHAR wszKeyName
[strlenW(wszFilterSlash
) + (CHARS_IN_GUID
-1) + 1];
1234 TRACE("(%p)->(%s, %s, %lx)\n", iface
, debugstr_guid(&clsid
), debugstr_w(szName
), dwMerit
);
1236 hr
= StringFromCLSID(&clsid
, &wszClsid
);
1240 strcpyW(wszKeyName
, wszFilterSlash
);
1241 strcatW(wszKeyName
, wszClsid
);
1243 lRet
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
);
1244 hr
= HRESULT_FROM_WIN32(lRet
);
1249 lRet
= RegSetValueExW(hKey
, NULL
, 0, REG_SZ
, (const BYTE
*)szName
, strlenW(szName
) + 1);
1250 hr
= HRESULT_FROM_WIN32(lRet
);
1256 strcpyW(wszKeyName
, wszClsidSlash
);
1257 strcatW(wszKeyName
, wszClsid
);
1259 lRet
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
);
1260 hr
= HRESULT_FROM_WIN32(lRet
);
1265 lRet
= RegSetValueExW(hKey
, wszMeritName
, 0, REG_DWORD
, (LPBYTE
)&dwMerit
, sizeof(dwMerit
));
1266 hr
= HRESULT_FROM_WIN32(lRet
);
1273 static HRESULT WINAPI
FilterMapper_RegisterFilterInstance(IFilterMapper
* iface
, CLSID clsid
, LPCWSTR szName
, CLSID
*MRId
)
1275 TRACE("(%p)->(%s, %s, %p)\n", iface
, debugstr_guid(&clsid
), debugstr_w(szName
), MRId
);
1277 /* Not implemented in Windows (tested on Win2k) */
1282 static HRESULT WINAPI
FilterMapper_RegisterPin(
1283 IFilterMapper
* iface
,
1290 CLSID ConnectsToFilter
,
1291 LPCWSTR ConnectsToPin
)
1295 LPWSTR wszClsid
= NULL
;
1297 HKEY hPinsKey
= NULL
;
1298 WCHAR
* wszPinsKeyName
;
1299 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + (CHARS_IN_GUID
-1) + 1];
1301 TRACE("(%p)->(%s, %s, %d, %d, %d, %d, %s, %s)\n", iface
, debugstr_guid(&Filter
), debugstr_w(szName
), bRendered
,
1302 bOutput
, bZero
, bMany
, debugstr_guid(&ConnectsToFilter
), debugstr_w(ConnectsToPin
));
1304 hr
= StringFromCLSID(&Filter
, &wszClsid
);
1308 strcpyW(wszKeyName
, wszClsidSlash
);
1309 strcatW(wszKeyName
, wszClsid
);
1311 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, KEY_WRITE
, &hKey
);
1312 hr
= HRESULT_FROM_WIN32(lRet
);
1317 wszPinsKeyName
= CoTaskMemAlloc((strlenW(wszPins
) + 1 + strlenW(szName
) + 1) * 2);
1318 if (!wszPinsKeyName
)
1324 strcpyW(wszPinsKeyName
, wszPins
);
1325 strcatW(wszPinsKeyName
, wszSlash
);
1326 strcatW(wszPinsKeyName
, szName
);
1328 lRet
= RegCreateKeyExW(hKey
, wszPinsKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hPinsKey
, NULL
);
1329 hr
= HRESULT_FROM_WIN32(lRet
);
1330 CoTaskMemFree(wszPinsKeyName
);
1335 lRet
= RegSetValueExW(hPinsKey
, wszAllowedMany
, 0, REG_DWORD
, (LPBYTE
)&bMany
, sizeof(bMany
));
1336 hr
= HRESULT_FROM_WIN32(lRet
);
1341 lRet
= RegSetValueExW(hPinsKey
, wszAllowedZero
, 0, REG_DWORD
, (LPBYTE
)&bZero
, sizeof(bZero
));
1342 hr
= HRESULT_FROM_WIN32(lRet
);
1347 lRet
= RegSetValueExW(hPinsKey
, wszDirection
, 0, REG_DWORD
, (LPBYTE
)&bOutput
, sizeof(bOutput
));
1348 hr
= HRESULT_FROM_WIN32(lRet
);
1353 lRet
= RegSetValueExW(hPinsKey
, wszIsRendered
, 0, REG_DWORD
, (LPBYTE
)&bRendered
, sizeof(bRendered
));
1354 hr
= HRESULT_FROM_WIN32(lRet
);
1359 lRet
= RegCreateKeyExW(hPinsKey
, wszTypes
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, NULL
, NULL
);
1360 hr
= HRESULT_FROM_WIN32(lRet
);
1364 CoTaskMemFree(wszClsid
);
1368 CloseHandle(hPinsKey
);
1374 static HRESULT WINAPI
FilterMapper_RegisterPinType(
1375 IFilterMapper
* iface
,
1383 LPWSTR wszClsid
= NULL
;
1384 LPWSTR wszClsidMajorType
= NULL
;
1385 LPWSTR wszClsidSubType
= NULL
;
1387 WCHAR
* wszTypesKey
;
1388 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + (CHARS_IN_GUID
-1) + 1];
1390 TRACE("(%p)->(%s, %s, %s, %s)\n", iface
, debugstr_guid(&clsFilter
), debugstr_w(szName
),
1391 debugstr_guid(&clsMajorType
), debugstr_guid(&clsSubType
));
1393 hr
= StringFromCLSID(&clsFilter
, &wszClsid
);
1397 hr
= StringFromCLSID(&clsMajorType
, &wszClsidMajorType
);
1402 hr
= StringFromCLSID(&clsSubType
, &wszClsidSubType
);
1407 wszTypesKey
= CoTaskMemAlloc((strlenW(wszClsidSlash
) + strlenW(wszClsid
) + strlenW(wszPins
) +
1408 strlenW(szName
) + strlenW(wszTypes
) + 3 + 1) * 2);
1415 strcpyW(wszTypesKey
, wszClsidSlash
);
1416 strcatW(wszTypesKey
, wszClsid
);
1417 strcatW(wszTypesKey
, wszSlash
);
1418 strcatW(wszTypesKey
, wszPins
);
1419 strcatW(wszTypesKey
, wszSlash
);
1420 strcatW(wszTypesKey
, szName
);
1421 strcatW(wszTypesKey
, wszSlash
);
1422 strcatW(wszTypesKey
, wszTypes
);
1424 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszTypesKey
, 0, KEY_WRITE
, &hKey
);
1425 hr
= HRESULT_FROM_WIN32(lRet
);
1426 CoTaskMemFree(wszTypesKey
);
1431 strcpyW(wszKeyName
, wszClsidMajorType
);
1432 strcatW(wszKeyName
, wszSlash
);
1433 strcatW(wszKeyName
, wszClsidSubType
);
1435 lRet
= RegCreateKeyExW(hKey
, wszKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, NULL
, NULL
);
1436 hr
= HRESULT_FROM_WIN32(lRet
);
1441 CoTaskMemFree(wszClsid
);
1442 if (wszClsidMajorType
)
1443 CoTaskMemFree(wszClsidMajorType
);
1444 if (wszClsidSubType
)
1445 CoTaskMemFree(wszClsidSubType
);
1450 static HRESULT WINAPI
FilterMapper_UnregisterFilter(IFilterMapper
* iface
, CLSID Filter
)
1454 LPWSTR wszClsid
= NULL
;
1456 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + (CHARS_IN_GUID
-1) + 1];
1458 TRACE("(%p)->(%s)\n", iface
, debugstr_guid(&Filter
));
1460 hr
= StringFromCLSID(&Filter
, &wszClsid
);
1464 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszFilter
, 0, KEY_WRITE
, &hKey
);
1465 hr
= HRESULT_FROM_WIN32(lRet
);
1470 lRet
= RegDeleteKeyW(hKey
, wszClsid
);
1471 hr
= HRESULT_FROM_WIN32(lRet
);
1477 strcpyW(wszKeyName
, wszClsidSlash
);
1478 strcatW(wszKeyName
, wszClsid
);
1480 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, KEY_WRITE
, &hKey
);
1481 hr
= HRESULT_FROM_WIN32(lRet
);
1486 lRet
= RegDeleteKeyW(hKey
, wszMeritName
);
1487 hr
= HRESULT_FROM_WIN32(lRet
);
1492 CoTaskMemFree(wszClsid
);
1497 static HRESULT WINAPI
FilterMapper_UnregisterFilterInstance(IFilterMapper
* iface
, CLSID MRId
)
1499 TRACE("(%p)->(%s)\n", iface
, debugstr_guid(&MRId
));
1501 /* Not implemented in Windows (tested on Win2k) */
1506 static HRESULT WINAPI
FilterMapper_UnregisterPin(IFilterMapper
* iface
, CLSID Filter
, LPCWSTR Name
)
1510 LPWSTR wszClsid
= NULL
;
1512 WCHAR
* wszPinNameKey
;
1513 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + (CHARS_IN_GUID
-1) + 1];
1515 TRACE("(%p)->(%s, %s)\n", iface
, debugstr_guid(&Filter
), debugstr_w(Name
));
1518 return E_INVALIDARG
;
1520 hr
= StringFromCLSID(&Filter
, &wszClsid
);
1524 strcpyW(wszKeyName
, wszClsidSlash
);
1525 strcatW(wszKeyName
, wszClsid
);
1527 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, KEY_WRITE
, &hKey
);
1528 hr
= HRESULT_FROM_WIN32(lRet
);
1533 wszPinNameKey
= CoTaskMemAlloc((strlenW(wszPins
) + 1 + strlenW(Name
) + 1) * 2);
1540 strcpyW(wszPinNameKey
, wszPins
);
1541 strcatW(wszPinNameKey
, wszSlash
);
1542 strcatW(wszPinNameKey
, Name
);
1544 lRet
= RegDeleteKeyW(hKey
, wszPinNameKey
);
1545 hr
= HRESULT_FROM_WIN32(lRet
);
1546 CoTaskMemFree(wszPinNameKey
);
1550 CoTaskMemFree(wszClsid
);
1557 static const IFilterMapperVtbl fmvtbl
=
1560 FilterMapper_QueryInterface
,
1561 FilterMapper_AddRef
,
1562 FilterMapper_Release
,
1564 FilterMapper_RegisterFilter
,
1565 FilterMapper_RegisterFilterInstance
,
1566 FilterMapper_RegisterPin
,
1567 FilterMapper_RegisterPinType
,
1568 FilterMapper_UnregisterFilter
,
1569 FilterMapper_UnregisterFilterInstance
,
1570 FilterMapper_UnregisterPin
,
1571 FilterMapper_EnumMatchingFilters