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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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];
251 TRACE("(%s, %lx, %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 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
));
272 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, wszFriendlyName
, 0, REG_SZ
, (const BYTE
*)szDescription
, (strlenW(szDescription
) + 1) * sizeof(WCHAR
)));
277 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, wszClsidName
, 0, REG_SZ
, (LPBYTE
)wClsidCategory
, (strlenW(wClsidCategory
) + 1) * sizeof(WCHAR
)));
282 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, wszMeritName
, 0, REG_DWORD
, (LPBYTE
)&dwCategoryMerit
, sizeof(dwCategoryMerit
)));
288 CoTaskMemFree(wClsidCategory
);
290 CoTaskMemFree(wClsidAMCat
);
295 static HRESULT WINAPI
FilterMapper2_UnregisterFilter(
296 IFilterMapper2
* iface
,
297 const CLSID
*pclsidCategory
,
298 const OLECHAR
*szInstance
,
301 WCHAR wszKeyName
[MAX_PATH
];
302 LPWSTR wClsidCategory
= NULL
;
303 LPWSTR wFilter
= NULL
;
306 TRACE("(%p, %s, %s)\n", pclsidCategory
, debugstr_w(szInstance
), debugstr_guid(Filter
));
309 pclsidCategory
= &CLSID_LegacyAmFilterCategory
;
311 hr
= StringFromCLSID(pclsidCategory
, &wClsidCategory
);
315 strcpyW(wszKeyName
, wszClsidSlash
);
316 strcatW(wszKeyName
, wClsidCategory
);
317 strcatW(wszKeyName
, wszSlashInstance
);
319 strcatW(wszKeyName
, szInstance
);
322 hr
= StringFromCLSID(Filter
, &wFilter
);
324 strcatW(wszKeyName
, wFilter
);
330 hr
= HRESULT_FROM_WIN32(RegDeleteKeyW(HKEY_CLASSES_ROOT
, wszKeyName
));
334 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
);
366 CoTaskMemFree(wszClsid
);
370 static HRESULT
FM2_WriteFilterData(IPropertyBag
* pPropBag
, const REGFILTER2
* prf2
)
373 int size
= sizeof(struct REG_RF
);
375 struct Vector mainStore
= {NULL
, 0, 0};
376 struct Vector clsidStore
= {NULL
, 0, 0};
379 SAFEARRAYBOUND saBound
;
382 rrf
.dwVersion
= prf2
->dwVersion
;
383 rrf
.dwMerit
= prf2
->dwMerit
;
384 rrf
.dwPins
= prf2
->u
.s1
.cPins2
;
387 add_data(&mainStore
, (LPBYTE
)&rrf
, sizeof(rrf
));
389 for (i
= 0; i
< prf2
->u
.s1
.cPins2
; i
++)
391 size
+= sizeof(struct REG_RFP
);
392 if (prf2
->u
.s1
.rgPins2
[i
].clsPinCategory
)
393 size
+= sizeof(DWORD
);
394 size
+= prf2
->u
.s1
.rgPins2
[i
].nMediaTypes
* sizeof(struct REG_TYPE
);
395 size
+= prf2
->u
.s1
.rgPins2
[i
].nMediums
* sizeof(DWORD
);
398 for (i
= 0; i
< prf2
->u
.s1
.cPins2
; i
++)
401 REGFILTERPINS2 rgPin2
= prf2
->u
.s1
.rgPins2
[i
];
404 rrfp
.signature
[0] = '0';
405 rrfp
.signature
[1] = 'p';
406 rrfp
.signature
[2] = 'i';
407 rrfp
.signature
[3] = '3';
408 rrfp
.signature
[0] += i
;
409 rrfp
.dwFlags
= rgPin2
.dwFlags
;
410 rrfp
.dwInstances
= rgPin2
.cInstances
;
411 rrfp
.dwMediaTypes
= rgPin2
.nMediaTypes
;
412 rrfp
.dwMediums
= rgPin2
.nMediums
;
413 rrfp
.bCategory
= rgPin2
.clsPinCategory
? 1 : 0;
415 add_data(&mainStore
, (LPBYTE
)&rrfp
, sizeof(rrfp
));
418 DWORD index
= find_data(&clsidStore
, (const BYTE
*)rgPin2
.clsPinCategory
, sizeof(CLSID
));
420 index
= add_data(&clsidStore
, (const BYTE
*)rgPin2
.clsPinCategory
, sizeof(CLSID
));
423 add_data(&mainStore
, (LPBYTE
)&index
, sizeof(index
));
426 for (j
= 0; j
< rgPin2
.nMediaTypes
; j
++)
429 rt
.signature
[0] = '0';
430 rt
.signature
[1] = 't';
431 rt
.signature
[2] = 'y';
432 rt
.signature
[3] = '3';
433 rt
.signature
[0] += j
;
436 rt
.dwOffsetMajor
= find_data(&clsidStore
, (const BYTE
*)rgPin2
.lpMediaType
[j
].clsMajorType
, sizeof(CLSID
));
437 if (rt
.dwOffsetMajor
== -1)
438 rt
.dwOffsetMajor
= add_data(&clsidStore
, (const BYTE
*)rgPin2
.lpMediaType
[j
].clsMajorType
, sizeof(CLSID
));
439 rt
.dwOffsetMajor
+= size
;
440 rt
.dwOffsetMinor
= find_data(&clsidStore
, (const BYTE
*)rgPin2
.lpMediaType
[j
].clsMinorType
, sizeof(CLSID
));
441 if (rt
.dwOffsetMinor
== -1)
442 rt
.dwOffsetMinor
= add_data(&clsidStore
, (const BYTE
*)rgPin2
.lpMediaType
[j
].clsMinorType
, sizeof(CLSID
));
443 rt
.dwOffsetMinor
+= size
;
445 add_data(&mainStore
, (LPBYTE
)&rt
, sizeof(rt
));
448 for (j
= 0; j
< rgPin2
.nMediums
; j
++)
450 DWORD index
= find_data(&clsidStore
, (const BYTE
*)(rgPin2
.lpMedium
+ j
), sizeof(REGPINMEDIUM
));
452 index
= add_data(&clsidStore
, (const BYTE
*)(rgPin2
.lpMedium
+ j
), sizeof(REGPINMEDIUM
));
455 add_data(&mainStore
, (LPBYTE
)&index
, sizeof(index
));
460 saBound
.cElements
= mainStore
.current
+ clsidStore
.current
;
461 psa
= SafeArrayCreate(VT_UI1
, 1, &saBound
);
464 ERR("Couldn't create SAFEARRAY\n");
471 hr
= SafeArrayAccessData(psa
, (LPVOID
*)&pbSAData
);
474 memcpy(pbSAData
, mainStore
.pData
, mainStore
.current
);
475 memcpy(pbSAData
+ mainStore
.current
, clsidStore
.pData
, clsidStore
.current
);
476 hr
= SafeArrayUnaccessData(psa
);
480 V_VT(&var
) = VT_ARRAY
| VT_UI1
;
481 V_UNION(&var
, parray
) = psa
;
484 hr
= IPropertyBag_Write(pPropBag
, wszFilterDataName
, &var
);
487 SafeArrayDestroy(psa
);
489 delete_vector(&mainStore
);
490 delete_vector(&clsidStore
);
494 static HRESULT
FM2_ReadFilterData(IPropertyBag
* pPropBag
, REGFILTER2
* prf2
)
499 struct REG_RF
* prrf
;
502 REGFILTERPINS2
* rgPins2
;
505 V_VT(&var
) = VT_ARRAY
| VT_UI1
;
507 hr
= IPropertyBag_Read(pPropBag
, wszFilterDataName
, &var
, NULL
);
510 hr
= SafeArrayAccessData(V_UNION(&var
, parray
), (LPVOID
*)&pData
);
514 prrf
= (struct REG_RF
*)pData
;
517 if (prrf
->dwVersion
!= 2)
519 FIXME("Filter registry version %ld not supported\n", prrf
->dwVersion
);
520 ZeroMemory(prf2
, sizeof(*prf2
));
527 TRACE("version = %ld, merit = %lx, #pins = %ld, unused = %lx\n",
528 prrf
->dwVersion
, prrf
->dwMerit
, prrf
->dwPins
, prrf
->dwUnused
);
530 prf2
->dwVersion
= prrf
->dwVersion
;
531 prf2
->dwMerit
= prrf
->dwMerit
;
532 prf2
->u
.s1
.cPins2
= prrf
->dwPins
;
533 rgPins2
= CoTaskMemAlloc(prrf
->dwPins
* sizeof(*rgPins2
));
534 prf2
->u
.s1
.rgPins2
= rgPins2
;
535 pCurrent
+= sizeof(struct REG_RF
);
537 for (i
= 0; i
< prrf
->dwPins
; i
++)
539 struct REG_RFP
* prrfp
= (struct REG_RFP
*)pCurrent
;
540 REGPINTYPES
* lpMediaType
;
541 REGPINMEDIUM
* lpMedium
;
544 /* FIXME: check signature */
546 TRACE("\tsignature = %s\n", debugstr_an((const char*)prrfp
->signature
, 4));
548 TRACE("\tpin[%ld]: flags = %lx, instances = %ld, media types = %ld, mediums = %ld\n",
549 i
, prrfp
->dwFlags
, prrfp
->dwInstances
, prrfp
->dwMediaTypes
, prrfp
->dwMediums
);
551 rgPins2
[i
].dwFlags
= prrfp
->dwFlags
;
552 rgPins2
[i
].cInstances
= prrfp
->dwInstances
;
553 rgPins2
[i
].nMediaTypes
= prrfp
->dwMediaTypes
;
554 rgPins2
[i
].nMediums
= prrfp
->dwMediums
;
555 pCurrent
+= sizeof(struct REG_RFP
);
556 if (prrfp
->bCategory
)
558 CLSID
* clsCat
= CoTaskMemAlloc(sizeof(CLSID
));
559 memcpy(clsCat
, pData
+ *(DWORD
*)(pCurrent
), sizeof(CLSID
));
560 pCurrent
+= sizeof(DWORD
);
561 rgPins2
[i
].clsPinCategory
= clsCat
;
564 rgPins2
[i
].clsPinCategory
= NULL
;
566 if (rgPins2
[i
].nMediaTypes
> 0)
567 lpMediaType
= CoTaskMemAlloc(rgPins2
[i
].nMediaTypes
* sizeof(*lpMediaType
));
571 rgPins2
[i
].lpMediaType
= lpMediaType
;
573 for (j
= 0; j
< rgPins2
[i
].nMediaTypes
; j
++)
575 struct REG_TYPE
* prt
= (struct REG_TYPE
*)pCurrent
;
576 CLSID
* clsMajor
= CoTaskMemAlloc(sizeof(CLSID
));
577 CLSID
* clsMinor
= CoTaskMemAlloc(sizeof(CLSID
));
579 /* FIXME: check signature */
580 TRACE("\t\tsignature = %s\n", debugstr_an((const char*)prt
->signature
, 4));
582 memcpy(clsMajor
, pData
+ prt
->dwOffsetMajor
, sizeof(CLSID
));
583 memcpy(clsMinor
, pData
+ prt
->dwOffsetMinor
, sizeof(CLSID
));
585 lpMediaType
[j
].clsMajorType
= clsMajor
;
586 lpMediaType
[j
].clsMinorType
= clsMinor
;
588 pCurrent
+= sizeof(*prt
);
591 if (rgPins2
[i
].nMediums
> 0)
592 lpMedium
= CoTaskMemAlloc(rgPins2
[i
].nMediums
* sizeof(*lpMedium
));
596 rgPins2
[i
].lpMedium
= lpMedium
;
598 for (j
= 0; j
< rgPins2
[i
].nMediums
; j
++)
600 DWORD dwOffset
= *(DWORD
*)pCurrent
;
602 memcpy(lpMedium
+ j
, pData
+ dwOffset
, sizeof(REGPINMEDIUM
));
604 pCurrent
+= sizeof(dwOffset
);
611 SafeArrayUnaccessData(V_UNION(&var
, parray
));
618 static void FM2_DeleteRegFilter(REGFILTER2
* prf2
)
621 for (i
= 0; i
< prf2
->u
.s1
.cPins2
; i
++)
624 if (prf2
->u
.s1
.rgPins2
[i
].clsPinCategory
)
625 CoTaskMemFree((LPVOID
)prf2
->u
.s1
.rgPins2
[i
].clsPinCategory
);
627 for (j
= 0; j
< prf2
->u
.s1
.rgPins2
[i
].nMediaTypes
; j
++)
629 CoTaskMemFree((LPVOID
)prf2
->u
.s1
.rgPins2
[i
].lpMediaType
[j
].clsMajorType
);
630 CoTaskMemFree((LPVOID
)prf2
->u
.s1
.rgPins2
[i
].lpMediaType
[j
].clsMinorType
);
632 CoTaskMemFree((LPVOID
)prf2
->u
.s1
.rgPins2
[i
].lpMedium
);
636 static HRESULT WINAPI
FilterMapper2_RegisterFilter(
637 IFilterMapper2
* iface
,
638 REFCLSID clsidFilter
,
640 IMoniker
**ppMoniker
,
641 const CLSID
*pclsidCategory
,
642 const OLECHAR
*szInstance
,
643 const REGFILTER2
*prf2
)
645 IParseDisplayName
* pParser
= NULL
;
646 IBindCtx
* pBindCtx
= NULL
;
647 IMoniker
* pMoniker
= NULL
;
648 IPropertyBag
* pPropBag
= NULL
;
650 LPWSTR pwszParseName
= NULL
;
652 static const WCHAR wszDevice
[] = {'@','d','e','v','i','c','e',':','s','w',':',0};
655 LPWSTR szClsidTemp
= NULL
;
656 REGFILTER2 regfilter2
;
657 REGFILTERPINS2
* pregfp2
= NULL
;
659 TRACE("(%s, %s, %p, %s, %s, %p)\n",
660 debugstr_guid(clsidFilter
),
663 debugstr_guid(pclsidCategory
),
664 debugstr_w(szInstance
),
667 if (prf2
->dwVersion
== 2)
671 else if (prf2
->dwVersion
== 1)
675 /* REGFILTER2 structure is converted from version 1 to 2. Tested on Win2k. */
676 regfilter2
.dwVersion
= 2;
677 regfilter2
.dwMerit
= prf2
->dwMerit
;
678 regfilter2
.u
.s1
.cPins2
= prf2
->u
.s
.cPins
;
679 pregfp2
= (REGFILTERPINS2
*) CoTaskMemAlloc(prf2
->u
.s
.cPins
* sizeof(REGFILTERPINS2
));
680 regfilter2
.u
.s1
.rgPins2
= pregfp2
;
681 for (i
= 0; i
< prf2
->u
.s
.cPins
; i
++)
684 if (prf2
->u
.s
.rgPins
[i
].bRendered
)
685 flags
|= REG_PINFLAG_B_RENDERER
;
686 if (prf2
->u
.s
.rgPins
[i
].bOutput
)
687 flags
|= REG_PINFLAG_B_OUTPUT
;
688 if (prf2
->u
.s
.rgPins
[i
].bZero
)
689 flags
|= REG_PINFLAG_B_ZERO
;
690 if (prf2
->u
.s
.rgPins
[i
].bMany
)
691 flags
|= REG_PINFLAG_B_MANY
;
692 pregfp2
[i
].dwFlags
= flags
;
693 pregfp2
[i
].cInstances
= 1;
694 pregfp2
[i
].nMediaTypes
= prf2
->u
.s
.rgPins
[i
].nMediaTypes
;
695 pregfp2
[i
].lpMediaType
= prf2
->u
.s
.rgPins
[i
].lpMediaType
;
696 pregfp2
[i
].nMediums
= 0;
697 pregfp2
[i
].lpMedium
= NULL
;
698 pregfp2
[i
].clsPinCategory
= NULL
;
703 FIXME("dwVersion other that 1 or 2 not supported at the moment\n");
711 /* MSDN mentions the inexistent CLSID_ActiveMovieFilters GUID.
712 * In fact this is the CLSID_LegacyAmFilterCategory one */
713 pclsidCategory
= &CLSID_LegacyAmFilterCategory
;
715 /* sizeof... will include the null terminator and
716 * the + 1 is for the separator ('\\'). The -1 is
717 * because CHARS_IN_GUID includes the null terminator
719 nameLen
= sizeof(wszDevice
)/sizeof(wszDevice
[0]) + CHARS_IN_GUID
- 1 + 1;
722 nameLen
+= strlenW(szInstance
);
724 nameLen
+= CHARS_IN_GUID
- 1; /* CHARS_IN_GUID includes null terminator */
726 pCurrent
= pwszParseName
= CoTaskMemAlloc(nameLen
*sizeof(WCHAR
));
728 return E_OUTOFMEMORY
;
730 strcpyW(pwszParseName
, wszDevice
);
731 pCurrent
+= strlenW(wszDevice
);
733 hr
= StringFromCLSID(pclsidCategory
, &szClsidTemp
);
737 memcpy(pCurrent
, szClsidTemp
, CHARS_IN_GUID
* sizeof(WCHAR
));
738 pCurrent
+= CHARS_IN_GUID
- 1;
742 strcpyW(pCurrent
+1, szInstance
);
747 CoTaskMemFree(szClsidTemp
);
750 hr
= StringFromCLSID(clsidFilter
, &szClsidTemp
);
752 strcpyW(pCurrent
+1, szClsidTemp
);
757 hr
= CoCreateInstance(&CLSID_CDeviceMoniker
, NULL
, CLSCTX_INPROC
, &IID_IParseDisplayName
, (LPVOID
*)&pParser
);
760 hr
= CreateBindCtx(0, &pBindCtx
);
763 hr
= IParseDisplayName_ParseDisplayName(pParser
, pBindCtx
, pwszParseName
, &ulEaten
, &pMoniker
);
766 IBindCtx_Release(pBindCtx
);
768 IParseDisplayName_Release(pParser
);
771 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
)&pPropBag
);
774 hr
= FM2_WriteFriendlyName(pPropBag
, szName
);
777 hr
= FM2_WriteClsid(pPropBag
, clsidFilter
);
780 hr
= FM2_WriteFilterData(pPropBag
, ®filter2
);
783 IPropertyBag_Release(pPropBag
);
785 CoTaskMemFree(szClsidTemp
);
787 if (SUCCEEDED(hr
) && ppMoniker
)
788 *ppMoniker
= pMoniker
;
790 IMoniker_Release(pMoniker
);
793 CoTaskMemFree(pregfp2
);
795 TRACE("-- returning %lx\n", hr
);
800 /* internal helper function */
801 static BOOL
MatchTypes(
804 const REGPINTYPES
* pPinTypes
,
806 const GUID
* pMatchTypes
)
811 if ((nMatchTypes
== 0) && (nPinTypes
> 0))
814 for (j
= 0; j
< nPinTypes
; j
++)
817 for (i
= 0; i
< nMatchTypes
*2; i
+=2)
819 if (((!bExactMatch
&& IsEqualGUID(pPinTypes
[j
].clsMajorType
, &GUID_NULL
)) || IsEqualGUID(&pMatchTypes
[i
], &GUID_NULL
) || IsEqualGUID(pPinTypes
[j
].clsMajorType
, &pMatchTypes
[i
])) &&
820 ((!bExactMatch
&& IsEqualGUID(pPinTypes
[j
].clsMinorType
, &GUID_NULL
)) || IsEqualGUID(&pMatchTypes
[i
+1], &GUID_NULL
) || IsEqualGUID(pPinTypes
[j
].clsMinorType
, &pMatchTypes
[i
+1])))
830 /* internal helper function for qsort of MONIKER_MERIT array */
831 static int mm_compare(const void * left
, const void * right
)
833 const struct MONIKER_MERIT
* mmLeft
= (const struct MONIKER_MERIT
*)left
;
834 const struct MONIKER_MERIT
* mmRight
= (const struct MONIKER_MERIT
*)right
;
836 if (mmLeft
->dwMerit
== mmRight
->dwMerit
)
838 if (mmLeft
->dwMerit
> mmRight
->dwMerit
)
844 * Exact match means whether or not to treat GUID_NULL's in filter data as wild cards
845 * (GUID_NULL's in input to function automatically treated as wild cards)
846 * Input/Output needed means match only on criteria if TRUE (with zero input types
847 * meaning match any input/output pin as long as one exists), otherwise match any
848 * filter that meets the rest of the requirements.
850 static HRESULT WINAPI
FilterMapper2_EnumMatchingFilters(
851 IFilterMapper2
* iface
,
852 IEnumMoniker
**ppEnum
,
858 const GUID
*pInputTypes
,
859 const REGPINMEDIUM
*pMedIn
,
860 const CLSID
*pPinCategoryIn
,
864 const GUID
*pOutputTypes
,
865 const REGPINMEDIUM
*pMedOut
,
866 const CLSID
*pPinCategoryOut
)
868 ICreateDevEnum
* pCreateDevEnum
;
869 IMoniker
* pMonikerCat
;
870 IEnumMoniker
* pEnumCat
;
872 struct Vector monikers
= {NULL
, 0, 0};
874 TRACE("(%p, %lx, %s, %lx, %s, %ld, %p, %p, %p, %s, %s, %p, %p, %p)\n",
877 bExactMatch
? "true" : "false",
879 bInputNeeded
? "true" : "false",
884 bRender
? "true" : "false",
885 bOutputNeeded
? "true" : "false",
892 FIXME("dwFlags = %lx not implemented\n", dwFlags
);
897 hr
= CoCreateInstance(&CLSID_SystemDeviceEnum
, NULL
, CLSCTX_INPROC
, &IID_ICreateDevEnum
, (LPVOID
*)&pCreateDevEnum
);
900 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &CLSID_ActiveMovieCategories
, &pEnumCat
, 0);
902 while (IEnumMoniker_Next(pEnumCat
, 1, &pMonikerCat
, NULL
) == S_OK
)
904 IPropertyBag
* pPropBagCat
= NULL
;
906 HRESULT hrSub
; /* this is so that one buggy filter
907 doesn't make the whole lot fail */
911 hrSub
= IMoniker_BindToStorage(pMonikerCat
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBagCat
);
913 if (SUCCEEDED(hrSub
))
914 hrSub
= IPropertyBag_Read(pPropBagCat
, wszMeritName
, &var
, NULL
);
916 if (SUCCEEDED(hrSub
) && (V_UNION(&var
, ulVal
) >= dwMerit
))
919 IEnumMoniker
* pEnum
;
924 if (TRACE_ON(quartz
))
927 V_VT(&temp
) = VT_EMPTY
;
928 IPropertyBag_Read(pPropBagCat
, wszFriendlyName
, &temp
, NULL
);
929 TRACE("Considering category %s\n", debugstr_w(V_UNION(&temp
, bstrVal
)));
933 hrSub
= IPropertyBag_Read(pPropBagCat
, wszClsidName
, &var
, NULL
);
935 if (SUCCEEDED(hrSub
))
936 hrSub
= CLSIDFromString(V_UNION(&var
, bstrVal
), &clsidCat
);
938 if (SUCCEEDED(hrSub
))
939 hrSub
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &clsidCat
, &pEnum
, 0);
943 while (IEnumMoniker_Next(pEnum
, 1, &pMoniker
, NULL
) == S_OK
)
945 IPropertyBag
* pPropBag
= NULL
;
948 BOOL bInputMatch
= !bInputNeeded
;
949 BOOL bOutputMatch
= !bOutputNeeded
;
951 ZeroMemory(&rf2
, sizeof(rf2
));
953 hrSub
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBag
);
955 if (TRACE_ON(quartz
))
958 V_VT(&temp
) = VT_EMPTY
;
959 IPropertyBag_Read(pPropBag
, wszFriendlyName
, &temp
, NULL
);
960 TRACE("Considering filter %s\n", debugstr_w(V_UNION(&temp
, bstrVal
)));
964 if (SUCCEEDED(hrSub
))
965 hrSub
= FM2_ReadFilterData(pPropBag
, &rf2
);
967 /* Logic used for bInputMatch expression:
968 * There exists some pin such that bInputNeeded implies (pin is an input and
969 * (bRender implies pin has render flag) and major/minor types members of
971 * bOutputMatch is similar, but without the "bRender implies ..." part
972 * and substituting variables names containing input for output
975 /* determine whether filter meets requirements */
976 if (SUCCEEDED(hrSub
) && (rf2
.dwMerit
>= dwMerit
))
978 for (i
= 0; (i
< rf2
.u
.s1
.cPins2
) && (!bInputMatch
|| !bOutputMatch
); i
++)
980 const REGFILTERPINS2
* rfp2
= rf2
.u
.s1
.rgPins2
+ i
;
982 bInputMatch
= bInputMatch
|| (!(rfp2
->dwFlags
& REG_PINFLAG_B_OUTPUT
) &&
983 (!bRender
|| (rfp2
->dwFlags
& REG_PINFLAG_B_RENDERER
)) &&
984 MatchTypes(bExactMatch
, rfp2
->nMediaTypes
, rfp2
->lpMediaType
, cInputTypes
, pInputTypes
));
985 bOutputMatch
= bOutputMatch
|| ((rfp2
->dwFlags
& REG_PINFLAG_B_OUTPUT
) &&
986 MatchTypes(bExactMatch
, rfp2
->nMediaTypes
, rfp2
->lpMediaType
, cOutputTypes
, pOutputTypes
));
989 if (bInputMatch
&& bOutputMatch
)
991 struct MONIKER_MERIT mm
= {pMoniker
, rf2
.dwMerit
};
992 IMoniker_AddRef(pMoniker
);
993 add_data(&monikers
, (LPBYTE
)&mm
, sizeof(mm
));
997 FM2_DeleteRegFilter(&rf2
);
999 IPropertyBag_Release(pPropBag
);
1000 IMoniker_Release(pMoniker
);
1002 IEnumMoniker_Release(pEnum
);
1008 IPropertyBag_Release(pPropBagCat
);
1009 IMoniker_Release(pMonikerCat
);
1014 IMoniker
** ppMoniker
;
1016 ULONG nMonikerCount
= monikers
.current
/ sizeof(struct MONIKER_MERIT
);
1018 /* sort the monikers in descending merit order */
1019 qsort(monikers
.pData
, nMonikerCount
,
1020 sizeof(struct MONIKER_MERIT
),
1023 /* construct an IEnumMoniker interface */
1024 ppMoniker
= CoTaskMemAlloc(nMonikerCount
* sizeof(IMoniker
*));
1025 for (i
= 0; i
< nMonikerCount
; i
++)
1027 /* no need to AddRef here as already AddRef'd above */
1028 ppMoniker
[i
] = ((struct MONIKER_MERIT
*)monikers
.pData
)[i
].pMoniker
;
1030 hr
= EnumMonikerImpl_Create(ppMoniker
, nMonikerCount
, ppEnum
);
1031 CoTaskMemFree(ppMoniker
);
1034 delete_vector(&monikers
);
1035 IEnumMoniker_Release(pEnumCat
);
1036 ICreateDevEnum_Release(pCreateDevEnum
);
1041 static const IFilterMapper2Vtbl fm2vtbl
=
1044 FilterMapper2_QueryInterface
,
1045 FilterMapper2_AddRef
,
1046 FilterMapper2_Release
,
1048 FilterMapper2_CreateCategory
,
1049 FilterMapper2_UnregisterFilter
,
1050 FilterMapper2_RegisterFilter
,
1051 FilterMapper2_EnumMatchingFilters
1054 /*** IUnknown methods ***/
1056 static HRESULT WINAPI
FilterMapper_QueryInterface(IFilterMapper
* iface
, REFIID riid
, LPVOID
*ppv
)
1058 FilterMapper2Impl
*This
= impl_from_IFilterMapper(iface
);
1060 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppv
);
1062 return FilterMapper2_QueryInterface((IFilterMapper2
*)&This
->lpVtbl
, riid
, ppv
);
1065 static ULONG WINAPI
FilterMapper_AddRef(IFilterMapper
* iface
)
1067 FilterMapper2Impl
*This
= impl_from_IFilterMapper(iface
);
1069 return FilterMapper2_AddRef((IFilterMapper2
*)This
);
1072 static ULONG WINAPI
FilterMapper_Release(IFilterMapper
* iface
)
1074 FilterMapper2Impl
*This
= impl_from_IFilterMapper(iface
);
1076 return FilterMapper2_Release((IFilterMapper2
*)This
);
1079 /*** IFilterMapper methods ***/
1081 static HRESULT WINAPI
FilterMapper_EnumMatchingFilters(
1082 IFilterMapper
* iface
,
1083 IEnumRegFilters
**ppEnum
,
1093 FilterMapper2Impl
*This
= impl_from_IFilterMapper(iface
);
1096 IEnumMoniker
* ppEnumMoniker
;
1099 ULONG idx
= 0, nb_mon
= 0;
1100 REGFILTER
* regfilters
;
1103 TRACE("(%p/%p)->(%p, %lx, %s, %s, %s, %s, %s, %s, %s) stub!\n",
1107 bInputNeeded
? "true" : "false",
1108 debugstr_guid(&clsInMaj
),
1109 debugstr_guid(&clsInSub
),
1110 bRender
? "true" : "false",
1111 bOutputNeeded
? "true" : "false",
1112 debugstr_guid(&clsOutMaj
),
1113 debugstr_guid(&clsOutSub
));
1115 InputType
[0] = clsInMaj
;
1116 InputType
[1] = clsInSub
;
1117 OutputType
[0] = clsOutMaj
;
1118 OutputType
[1] = clsOutSub
;
1120 hr
= IFilterMapper2_EnumMatchingFilters((IFilterMapper2
*)This
,
1140 while(IEnumMoniker_Next(ppEnumMoniker
, 1, &IMon
, &nb
) == S_OK
)
1142 IMoniker_Release(IMon
);
1149 IEnumMoniker_Release(ppEnumMoniker
);
1150 return IEnumRegFiltersImpl_Construct(NULL
, 0, ppEnum
);
1153 regfilters
= CoTaskMemAlloc(nb_mon
* sizeof(REGFILTER
));
1156 IEnumMoniker_Release(ppEnumMoniker
);
1157 return E_OUTOFMEMORY
;
1160 IEnumMoniker_Reset(ppEnumMoniker
);
1161 while(IEnumMoniker_Next(ppEnumMoniker
, 1, &IMon
, &nb
) == S_OK
)
1163 IPropertyBag
* pPropBagCat
= NULL
;
1170 V_VT(&var
) = VT_BSTR
;
1172 hrSub
= IMoniker_BindToStorage(IMon
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBagCat
);
1174 if (SUCCEEDED(hrSub
))
1175 hrSub
= IPropertyBag_Read(pPropBagCat
, wszClsidName
, &var
, NULL
);
1177 if (SUCCEEDED(hrSub
))
1178 hrSub
= CLSIDFromString(V_UNION(&var
, bstrVal
), &clsid
);
1180 if (SUCCEEDED(hrSub
))
1181 hrSub
= IPropertyBag_Read(pPropBagCat
, wszFriendlyName
, &var
, NULL
);
1183 if (SUCCEEDED(hrSub
))
1185 len
= (strlenW((WCHAR
*)&V_UNION(&var
, bstrVal
))+1) * sizeof(WCHAR
);
1186 if (!(regfilters
[idx
].Name
= CoTaskMemAlloc(len
*2)))
1190 if (SUCCEEDED(hrSub
))
1192 memcpy(regfilters
[idx
].Name
, &V_UNION(&var
, bstrVal
), len
);
1193 regfilters
[idx
].Clsid
= clsid
;
1198 IPropertyBag_Release(pPropBagCat
);
1199 IMoniker_Release(IMon
);
1202 /* In case of release all resources */
1205 for (idx
= 0; idx
< nb_mon
; idx
++)
1206 CoTaskMemFree(regfilters
[idx
].Name
);
1207 CoTaskMemFree(regfilters
);
1208 IEnumMoniker_Release(ppEnumMoniker
);
1212 hr
= IEnumRegFiltersImpl_Construct(regfilters
, nb_mon
, ppEnum
);
1213 CoTaskMemFree(regfilters
);
1214 IEnumMoniker_Release(ppEnumMoniker
);
1220 static HRESULT WINAPI
FilterMapper_RegisterFilter(IFilterMapper
* iface
, CLSID clsid
, LPCWSTR szName
, DWORD dwMerit
)
1223 LPWSTR wszClsid
= NULL
;
1225 WCHAR wszKeyName
[strlenW(wszFilterSlash
) + (CHARS_IN_GUID
-1) + 1];
1227 TRACE("(%p)->(%s, %s, %lx)\n", iface
, debugstr_guid(&clsid
), debugstr_w(szName
), dwMerit
);
1229 hr
= StringFromCLSID(&clsid
, &wszClsid
);
1233 strcpyW(wszKeyName
, wszFilterSlash
);
1234 strcatW(wszKeyName
, wszClsid
);
1236 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
));
1241 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, NULL
, 0, REG_SZ
, (const BYTE
*)szName
, strlenW(szName
) + 1));
1247 strcpyW(wszKeyName
, wszClsidSlash
);
1248 strcatW(wszKeyName
, wszClsid
);
1250 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
));
1255 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, wszMeritName
, 0, REG_DWORD
, (LPBYTE
)&dwMerit
, sizeof(dwMerit
)));
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
)
1283 LPWSTR wszClsid
= NULL
;
1285 HKEY hPinsKey
= NULL
;
1286 WCHAR
* wszPinsKeyName
;
1287 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + (CHARS_IN_GUID
-1) + 1];
1289 TRACE("(%p)->(%s, %s, %d, %d, %d, %d, %s, %s)\n", iface
, debugstr_guid(&Filter
), debugstr_w(szName
), bRendered
,
1290 bOutput
, bZero
, bMany
, debugstr_guid(&ConnectsToFilter
), debugstr_w(ConnectsToPin
));
1292 hr
= StringFromCLSID(&Filter
, &wszClsid
);
1296 strcpyW(wszKeyName
, wszClsidSlash
);
1297 strcatW(wszKeyName
, wszClsid
);
1299 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, KEY_WRITE
, &hKey
));
1304 wszPinsKeyName
= CoTaskMemAlloc((strlenW(wszPins
) + 1 + strlenW(szName
) + 1) * 2);
1305 if (!wszPinsKeyName
)
1311 strcpyW(wszPinsKeyName
, wszPins
);
1312 strcatW(wszPinsKeyName
, wszSlash
);
1313 strcatW(wszPinsKeyName
, szName
);
1315 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(hKey
, wszPinsKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hPinsKey
, NULL
));
1316 CoTaskMemFree(wszPinsKeyName
);
1321 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hPinsKey
, wszAllowedMany
, 0, REG_DWORD
, (LPBYTE
)&bMany
, sizeof(bMany
)));
1326 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hPinsKey
, wszAllowedZero
, 0, REG_DWORD
, (LPBYTE
)&bZero
, sizeof(bZero
)));
1331 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hPinsKey
, wszDirection
, 0, REG_DWORD
, (LPBYTE
)&bOutput
, sizeof(bOutput
)));
1336 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hPinsKey
, wszIsRendered
, 0, REG_DWORD
, (LPBYTE
)&bRendered
, sizeof(bRendered
)));
1341 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(hPinsKey
, wszTypes
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, NULL
, NULL
));
1345 CoTaskMemFree(wszClsid
);
1349 CloseHandle(hPinsKey
);
1355 static HRESULT WINAPI
FilterMapper_RegisterPinType(
1356 IFilterMapper
* iface
,
1363 LPWSTR wszClsid
= NULL
;
1364 LPWSTR wszClsidMajorType
= NULL
;
1365 LPWSTR wszClsidSubType
= NULL
;
1367 WCHAR
* wszTypesKey
;
1368 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + (CHARS_IN_GUID
-1) + 1];
1370 TRACE("(%p)->(%s, %s, %s, %s)\n", iface
, debugstr_guid(&clsFilter
), debugstr_w(szName
),
1371 debugstr_guid(&clsMajorType
), debugstr_guid(&clsSubType
));
1373 hr
= StringFromCLSID(&clsFilter
, &wszClsid
);
1377 hr
= StringFromCLSID(&clsMajorType
, &wszClsidMajorType
);
1382 hr
= StringFromCLSID(&clsSubType
, &wszClsidSubType
);
1387 wszTypesKey
= CoTaskMemAlloc((strlenW(wszClsidSlash
) + strlenW(wszClsid
) + strlenW(wszPins
) +
1388 strlenW(szName
) + strlenW(wszTypes
) + 3 + 1) * 2);
1395 strcpyW(wszTypesKey
, wszClsidSlash
);
1396 strcatW(wszTypesKey
, wszClsid
);
1397 strcatW(wszTypesKey
, wszSlash
);
1398 strcatW(wszTypesKey
, wszPins
);
1399 strcatW(wszTypesKey
, wszSlash
);
1400 strcatW(wszTypesKey
, szName
);
1401 strcatW(wszTypesKey
, wszSlash
);
1402 strcatW(wszTypesKey
, wszTypes
);
1404 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszTypesKey
, 0, KEY_WRITE
, &hKey
));
1405 CoTaskMemFree(wszTypesKey
);
1410 strcpyW(wszKeyName
, wszClsidMajorType
);
1411 strcatW(wszKeyName
, wszSlash
);
1412 strcatW(wszKeyName
, wszClsidSubType
);
1414 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(hKey
, wszKeyName
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, NULL
, NULL
));
1419 CoTaskMemFree(wszClsid
);
1420 if (wszClsidMajorType
)
1421 CoTaskMemFree(wszClsidMajorType
);
1422 if (wszClsidSubType
)
1423 CoTaskMemFree(wszClsidSubType
);
1428 static HRESULT WINAPI
FilterMapper_UnregisterFilter(IFilterMapper
* iface
, CLSID Filter
)
1431 LPWSTR wszClsid
= NULL
;
1433 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + (CHARS_IN_GUID
-1) + 1];
1435 TRACE("(%p)->(%s)\n", iface
, debugstr_guid(&Filter
));
1437 hr
= StringFromCLSID(&Filter
, &wszClsid
);
1441 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszFilter
, 0, KEY_WRITE
, &hKey
));
1446 hr
= HRESULT_FROM_WIN32(RegDeleteKeyW(hKey
, wszClsid
));
1452 strcpyW(wszKeyName
, wszClsidSlash
);
1453 strcatW(wszKeyName
, wszClsid
);
1455 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, KEY_WRITE
, &hKey
));
1460 hr
= HRESULT_FROM_WIN32(RegDeleteKeyW(hKey
, wszMeritName
));
1465 CoTaskMemFree(wszClsid
);
1470 static HRESULT WINAPI
FilterMapper_UnregisterFilterInstance(IFilterMapper
* iface
, CLSID MRId
)
1472 TRACE("(%p)->(%s)\n", iface
, debugstr_guid(&MRId
));
1474 /* Not implemented in Windows (tested on Win2k) */
1479 static HRESULT WINAPI
FilterMapper_UnregisterPin(IFilterMapper
* iface
, CLSID Filter
, LPCWSTR Name
)
1482 LPWSTR wszClsid
= NULL
;
1484 WCHAR
* wszPinNameKey
;
1485 WCHAR wszKeyName
[strlenW(wszClsidSlash
) + (CHARS_IN_GUID
-1) + 1];
1487 TRACE("(%p)->(%s, %s)\n", iface
, debugstr_guid(&Filter
), debugstr_w(Name
));
1490 return E_INVALIDARG
;
1492 hr
= StringFromCLSID(&Filter
, &wszClsid
);
1496 strcpyW(wszKeyName
, wszClsidSlash
);
1497 strcatW(wszKeyName
, wszClsid
);
1499 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszKeyName
, 0, KEY_WRITE
, &hKey
));
1504 wszPinNameKey
= CoTaskMemAlloc((strlenW(wszPins
) + 1 + strlenW(Name
) + 1) * 2);
1511 strcpyW(wszPinNameKey
, wszPins
);
1512 strcatW(wszPinNameKey
, wszSlash
);
1513 strcatW(wszPinNameKey
, Name
);
1515 hr
= HRESULT_FROM_WIN32(RegDeleteKeyW(hKey
, wszPinNameKey
));
1516 CoTaskMemFree(wszPinNameKey
);
1520 CoTaskMemFree(wszClsid
);
1527 static const IFilterMapperVtbl fmvtbl
=
1530 FilterMapper_QueryInterface
,
1531 FilterMapper_AddRef
,
1532 FilterMapper_Release
,
1534 FilterMapper_RegisterFilter
,
1535 FilterMapper_RegisterFilterInstance
,
1536 FilterMapper_RegisterPin
,
1537 FilterMapper_RegisterPinType
,
1538 FilterMapper_UnregisterFilter
,
1539 FilterMapper_UnregisterFilterInstance
,
1540 FilterMapper_UnregisterPin
,
1541 FilterMapper_EnumMatchingFilters