kernel32: Get rid of the last parameter to PROFILE_CopyEntry().
[wine.git] / dlls / devenum / devenum_main.c
blob01ddef4ef23b71e7e44ab9e76d5859976e301160
1 /*
2 * Device Enumeration
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"
23 #include "rpcproxy.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(devenum);
28 DECLSPEC_HIDDEN LONG dll_refs;
29 static HINSTANCE devenum_instance;
31 /***********************************************************************
32 * DllEntryPoint
34 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
36 TRACE("%p 0x%x %p\n", hinstDLL, fdwReason, fImpLoad);
38 switch(fdwReason) {
39 case DLL_PROCESS_ATTACH:
40 devenum_instance = hinstDLL;
41 DisableThreadLibraryCalls(hinstDLL);
42 break;
44 return TRUE;
47 struct class_factory
49 IClassFactory IClassFactory_iface;
50 IUnknown *obj;
53 static inline struct class_factory *impl_from_IClassFactory( IClassFactory *iface )
55 return CONTAINING_RECORD( iface, struct class_factory, IClassFactory_iface );
58 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID iid, void **obj)
60 TRACE("(%p, %s, %p)\n", iface, debugstr_guid(iid), obj);
62 if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IClassFactory))
64 IClassFactory_AddRef(iface);
65 *obj = iface;
66 return S_OK;
69 *obj = NULL;
70 WARN("no interface for %s\n", debugstr_guid(iid));
71 return E_NOINTERFACE;
74 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
76 DEVENUM_LockModule();
77 return 2;
80 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
82 DEVENUM_UnlockModule();
83 return 1;
86 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface,
87 IUnknown *outer, REFIID iid, void **obj)
89 struct class_factory *This = impl_from_IClassFactory( iface );
91 TRACE("(%p, %s, %p)\n", outer, debugstr_guid(iid), obj);
93 if (!obj) return E_POINTER;
95 if (outer) return CLASS_E_NOAGGREGATION;
97 return IUnknown_QueryInterface(This->obj, iid, obj);
100 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL lock)
102 if (lock)
103 DEVENUM_LockModule();
104 else
105 DEVENUM_UnlockModule();
106 return S_OK;
109 static const IClassFactoryVtbl ClassFactory_vtbl = {
110 ClassFactory_QueryInterface,
111 ClassFactory_AddRef,
112 ClassFactory_Release,
113 ClassFactory_CreateInstance,
114 ClassFactory_LockServer
117 static struct class_factory create_devenum_cf = { { &ClassFactory_vtbl }, (IUnknown *)&devenum_factory };
118 static struct class_factory device_moniker_cf = { { &ClassFactory_vtbl }, (IUnknown *)&devenum_parser };
120 /***********************************************************************
121 * DllGetClassObject (DEVENUM.@)
123 HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **obj)
125 TRACE("(%s, %s, %p)\n", debugstr_guid(clsid), debugstr_guid(iid), obj);
127 *obj = NULL;
129 if (IsEqualGUID(clsid, &CLSID_SystemDeviceEnum))
130 return IClassFactory_QueryInterface(&create_devenum_cf.IClassFactory_iface, iid, obj);
131 else if (IsEqualGUID(clsid, &CLSID_CDeviceMoniker))
132 return IClassFactory_QueryInterface(&device_moniker_cf.IClassFactory_iface, iid, obj);
134 FIXME("class %s not available\n", debugstr_guid(clsid));
135 return CLASS_E_CLASSNOTAVAILABLE;
138 /***********************************************************************
139 * DllCanUnloadNow (DEVENUM.@)
141 HRESULT WINAPI DllCanUnloadNow(void)
143 return dll_refs != 0 ? S_FALSE : S_OK;
146 /***********************************************************************
147 * DllRegisterServer (DEVENUM.@)
149 HRESULT WINAPI DllRegisterServer(void)
151 HRESULT res;
152 IFilterMapper2 * pMapper = NULL;
153 LPVOID mapvptr;
155 TRACE("\n");
157 res = __wine_register_resources( devenum_instance );
158 if (FAILED(res))
159 return res;
161 res = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC,
162 &IID_IFilterMapper2, &mapvptr);
163 if (SUCCEEDED(res))
165 pMapper = mapvptr;
167 IFilterMapper2_CreateCategory(pMapper, &CLSID_AudioCompressorCategory, MERIT_DO_NOT_USE, L"Audio Compressors");
168 IFilterMapper2_CreateCategory(pMapper, &CLSID_AudioInputDeviceCategory, MERIT_DO_NOT_USE, L"Audio Capture Sources");
169 IFilterMapper2_CreateCategory(pMapper, &CLSID_AudioRendererCategory, MERIT_NORMAL, L"Audio Renderers");
170 IFilterMapper2_CreateCategory(pMapper, &CLSID_DeviceControlCategory, MERIT_DO_NOT_USE, L"Device Control Filters");
171 IFilterMapper2_CreateCategory(pMapper, &CLSID_LegacyAmFilterCategory, MERIT_NORMAL, L"DirectShow Filters");
172 IFilterMapper2_CreateCategory(pMapper, &CLSID_MidiRendererCategory, MERIT_NORMAL, L"Midi Renderers");
173 IFilterMapper2_CreateCategory(pMapper, &CLSID_TransmitCategory, MERIT_DO_NOT_USE, L"External Renderers");
174 IFilterMapper2_CreateCategory(pMapper, &CLSID_VideoInputDeviceCategory, MERIT_DO_NOT_USE, L"Video Capture Sources");
175 IFilterMapper2_CreateCategory(pMapper, &CLSID_VideoCompressorCategory, MERIT_DO_NOT_USE, L"Video Compressors");
177 IFilterMapper2_Release(pMapper);
180 return res;
183 /***********************************************************************
184 * DllUnregisterServer (DEVENUM.@)
186 HRESULT WINAPI DllUnregisterServer(void)
188 FIXME("stub!\n");
189 return __wine_unregister_resources( devenum_instance );