2 * browseui - Internet Explorer / Windows Explorer standard UI
4 * Copyright 2001 John R. Sheets (for CodeWeavers)
5 * Copyright 2004 Mike McCormack (for CodeWeavers)
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
29 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(browseui);
42 LONG BROWSEUI_refCount = 0;
44 HINSTANCE browseui_hinstance = 0;
46 typedef HRESULT (WINAPI *LPFNCONSTRUCTOR)(IUnknown *pUnkOuter, IUnknown **ppvOut);
52 {&CLSID_ACLMulti, ACLMulti_Constructor},
56 typedef struct tagClassFactory
58 const IClassFactoryVtbl *vtbl;
62 static const IClassFactoryVtbl ClassFactoryVtbl;
64 static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut)
66 ClassFactory *This = CoTaskMemAlloc(sizeof(ClassFactory));
67 This->vtbl = &ClassFactoryVtbl;
70 *ppvOut = (LPVOID)This;
71 TRACE("Created class factory %p\n", This);
76 static void ClassFactory_Destructor(ClassFactory *This)
78 TRACE("Destroying class factory %p\n", This);
83 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppvOut)
86 if (IsEqualIID(riid, &IID_IClassFactory) || IsEqualIID(riid, &IID_IUnknown)) {
87 IClassFactory_AddRef(iface);
92 WARN("Unknown interface %s\n", debugstr_guid(riid));
96 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
98 ClassFactory *This = (ClassFactory *)iface;
99 return InterlockedIncrement(&This->ref);
102 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
104 ClassFactory *This = (ClassFactory *)iface;
105 ULONG ret = InterlockedDecrement(&This->ref);
108 ClassFactory_Destructor(This);
112 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *punkOuter, REFIID iid, LPVOID *ppvOut)
114 ClassFactory *This = (ClassFactory *)iface;
118 TRACE("(%p, %p, %s, %p)\n", iface, punkOuter, debugstr_guid(iid), ppvOut);
119 ret = This->ctor(punkOuter, &obj);
122 ret = IUnknown_QueryInterface(obj, iid, ppvOut);
123 IUnknown_Release(obj);
127 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
129 ClassFactory *This = (ClassFactory *)iface;
131 TRACE("(%p)->(%x)\n", This, fLock);
134 InterlockedIncrement(&BROWSEUI_refCount);
136 InterlockedDecrement(&BROWSEUI_refCount);
141 static const IClassFactoryVtbl ClassFactoryVtbl = {
143 ClassFactory_QueryInterface,
145 ClassFactory_Release,
148 ClassFactory_CreateInstance,
149 ClassFactory_LockServer
152 /*************************************************************************
155 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
157 TRACE("%p 0x%x %p\n", hinst, fdwReason, fImpLoad);
160 case DLL_WINE_PREATTACH:
161 return FALSE; /* prefer native version */
162 case DLL_PROCESS_ATTACH:
163 DisableThreadLibraryCalls(hinst);
164 browseui_hinstance = hinst;
170 /*************************************************************************
171 * DllCanUnloadNow (BROWSEUI.@)
173 HRESULT WINAPI DllCanUnloadNow(void)
175 return BROWSEUI_refCount ? S_FALSE : S_OK;
178 /***********************************************************************
179 * DllGetVersion (BROWSEUI.@)
181 HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *info)
183 if (info->cbSize != sizeof(DLLVERSIONINFO)) FIXME("support DLLVERSIONINFO2\n");
185 /* this is what IE6 on Windows 98 reports */
186 info->dwMajorVersion = 6;
187 info->dwMinorVersion = 0;
188 info->dwBuildNumber = 2600;
189 info->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
194 /***********************************************************************
195 * DllGetClassObject (BROWSEUI.@)
197 HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *ppvOut)
202 if (!IsEqualIID(iid, &IID_IUnknown) && !IsEqualIID(iid, &IID_IClassFactory))
203 return E_NOINTERFACE;
205 for (i = 0; ClassesTable[i].clsid != NULL; i++)
206 if (IsEqualCLSID(ClassesTable[i].clsid, clsid)) {
207 return ClassFactory_Constructor(ClassesTable[i].ctor, ppvOut);
209 FIXME("CLSID %s not supported\n", debugstr_guid(clsid));
210 return CLASS_E_CLASSNOTAVAILABLE;