4 * Copyright (C) 2002 John K. Hohm
5 * Copyright (C) 2002 Robert Shearman
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 #include "devenum_private.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(devenum
);
28 DECLSPEC_HIDDEN LONG dll_refs
;
32 IClassFactory IClassFactory_iface
;
36 static inline struct class_factory
*impl_from_IClassFactory( IClassFactory
*iface
)
38 return CONTAINING_RECORD( iface
, struct class_factory
, IClassFactory_iface
);
41 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID iid
, void **obj
)
43 TRACE("(%p, %s, %p)\n", iface
, debugstr_guid(iid
), obj
);
45 if (IsEqualGUID(iid
, &IID_IUnknown
) || IsEqualGUID(iid
, &IID_IClassFactory
))
47 IClassFactory_AddRef(iface
);
53 WARN("no interface for %s\n", debugstr_guid(iid
));
57 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
63 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
65 DEVENUM_UnlockModule();
69 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
,
70 IUnknown
*outer
, REFIID iid
, void **obj
)
72 struct class_factory
*This
= impl_from_IClassFactory( iface
);
74 TRACE("(%p, %s, %p)\n", outer
, debugstr_guid(iid
), obj
);
76 if (!obj
) return E_POINTER
;
78 if (outer
) return CLASS_E_NOAGGREGATION
;
80 return IUnknown_QueryInterface(This
->obj
, iid
, obj
);
83 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL lock
)
88 DEVENUM_UnlockModule();
92 static const IClassFactoryVtbl ClassFactory_vtbl
= {
93 ClassFactory_QueryInterface
,
96 ClassFactory_CreateInstance
,
97 ClassFactory_LockServer
100 static struct class_factory create_devenum_cf
= { { &ClassFactory_vtbl
}, (IUnknown
*)&devenum_factory
};
101 static struct class_factory device_moniker_cf
= { { &ClassFactory_vtbl
}, (IUnknown
*)&devenum_parser
};
103 /***********************************************************************
104 * DllGetClassObject (DEVENUM.@)
106 HRESULT WINAPI
DllGetClassObject(REFCLSID clsid
, REFIID iid
, void **obj
)
108 TRACE("(%s, %s, %p)\n", debugstr_guid(clsid
), debugstr_guid(iid
), obj
);
112 if (IsEqualGUID(clsid
, &CLSID_SystemDeviceEnum
))
113 return IClassFactory_QueryInterface(&create_devenum_cf
.IClassFactory_iface
, iid
, obj
);
114 else if (IsEqualGUID(clsid
, &CLSID_CDeviceMoniker
))
115 return IClassFactory_QueryInterface(&device_moniker_cf
.IClassFactory_iface
, iid
, obj
);
117 FIXME("class %s not available\n", debugstr_guid(clsid
));
118 return CLASS_E_CLASSNOTAVAILABLE
;
121 /***********************************************************************
122 * DllCanUnloadNow (DEVENUM.@)
124 HRESULT WINAPI
DllCanUnloadNow(void)
126 return dll_refs
!= 0 ? S_FALSE
: S_OK
;
129 /***********************************************************************
130 * DllRegisterServer (DEVENUM.@)
132 HRESULT WINAPI
DllRegisterServer(void)
135 IFilterMapper2
* pMapper
= NULL
;
140 res
= __wine_register_resources();
144 res
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC
,
145 &IID_IFilterMapper2
, &mapvptr
);
150 IFilterMapper2_CreateCategory(pMapper
, &CLSID_AudioCompressorCategory
, MERIT_DO_NOT_USE
, L
"Audio Compressors");
151 IFilterMapper2_CreateCategory(pMapper
, &CLSID_AudioInputDeviceCategory
, MERIT_DO_NOT_USE
, L
"Audio Capture Sources");
152 IFilterMapper2_CreateCategory(pMapper
, &CLSID_AudioRendererCategory
, MERIT_NORMAL
, L
"Audio Renderers");
153 IFilterMapper2_CreateCategory(pMapper
, &CLSID_DeviceControlCategory
, MERIT_DO_NOT_USE
, L
"Device Control Filters");
154 IFilterMapper2_CreateCategory(pMapper
, &CLSID_LegacyAmFilterCategory
, MERIT_NORMAL
, L
"DirectShow Filters");
155 IFilterMapper2_CreateCategory(pMapper
, &CLSID_MidiRendererCategory
, MERIT_NORMAL
, L
"Midi Renderers");
156 IFilterMapper2_CreateCategory(pMapper
, &CLSID_TransmitCategory
, MERIT_DO_NOT_USE
, L
"External Renderers");
157 IFilterMapper2_CreateCategory(pMapper
, &CLSID_VideoInputDeviceCategory
, MERIT_DO_NOT_USE
, L
"Video Capture Sources");
158 IFilterMapper2_CreateCategory(pMapper
, &CLSID_VideoCompressorCategory
, MERIT_DO_NOT_USE
, L
"Video Compressors");
160 IFilterMapper2_Release(pMapper
);
166 /***********************************************************************
167 * DllUnregisterServer (DEVENUM.@)
169 HRESULT WINAPI
DllUnregisterServer(void)
172 return __wine_unregister_resources();