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"
41 DEFINE_GUID(CLSID_CompCatCacheDaemon, 0x8C7461EF, 0x2b13, 0x11d2, 0xbe, 0x35, 0x30, 0x78, 0x30, 0x2c, 0x20, 0x30);
43 WINE_DEFAULT_DEBUG_CHANNEL(browseui);
45 LONG BROWSEUI_refCount = 0;
47 HINSTANCE BROWSEUI_hinstance = 0;
49 typedef HRESULT (WINAPI *LPFNCONSTRUCTOR)(IUnknown *pUnkOuter, IUnknown **ppvOut);
55 {&CLSID_ACLMulti, ACLMulti_Constructor},
56 {&CLSID_ProgressDialog, ProgressDialog_Constructor},
57 {&CLSID_CompCatCacheDaemon, CompCatCacheDaemon_Constructor},
61 typedef struct tagClassFactory
63 const IClassFactoryVtbl *vtbl;
67 static const IClassFactoryVtbl ClassFactoryVtbl;
69 static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut)
71 ClassFactory *This = CoTaskMemAlloc(sizeof(ClassFactory));
72 This->vtbl = &ClassFactoryVtbl;
75 *ppvOut = (LPVOID)This;
76 TRACE("Created class factory %p\n", This);
81 static void ClassFactory_Destructor(ClassFactory *This)
83 TRACE("Destroying class factory %p\n", This);
88 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppvOut)
91 if (IsEqualIID(riid, &IID_IClassFactory) || IsEqualIID(riid, &IID_IUnknown)) {
92 IClassFactory_AddRef(iface);
97 WARN("Unknown interface %s\n", debugstr_guid(riid));
101 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
103 ClassFactory *This = (ClassFactory *)iface;
104 return InterlockedIncrement(&This->ref);
107 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
109 ClassFactory *This = (ClassFactory *)iface;
110 ULONG ret = InterlockedDecrement(&This->ref);
113 ClassFactory_Destructor(This);
117 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *punkOuter, REFIID iid, LPVOID *ppvOut)
119 ClassFactory *This = (ClassFactory *)iface;
123 TRACE("(%p, %p, %s, %p)\n", iface, punkOuter, debugstr_guid(iid), ppvOut);
124 ret = This->ctor(punkOuter, &obj);
127 ret = IUnknown_QueryInterface(obj, iid, ppvOut);
128 IUnknown_Release(obj);
132 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
134 ClassFactory *This = (ClassFactory *)iface;
136 TRACE("(%p)->(%x)\n", This, fLock);
139 InterlockedIncrement(&BROWSEUI_refCount);
141 InterlockedDecrement(&BROWSEUI_refCount);
146 static const IClassFactoryVtbl ClassFactoryVtbl = {
148 ClassFactory_QueryInterface,
150 ClassFactory_Release,
153 ClassFactory_CreateInstance,
154 ClassFactory_LockServer
157 /*************************************************************************
160 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
162 TRACE("%p 0x%x %p\n", hinst, fdwReason, fImpLoad);
165 case DLL_WINE_PREATTACH:
166 return FALSE; /* prefer native version */
167 case DLL_PROCESS_ATTACH:
168 DisableThreadLibraryCalls(hinst);
169 BROWSEUI_hinstance = hinst;
175 /*************************************************************************
176 * DllCanUnloadNow (BROWSEUI.@)
178 HRESULT WINAPI DllCanUnloadNow(void)
180 return BROWSEUI_refCount ? S_FALSE : S_OK;
183 /***********************************************************************
184 * DllGetVersion (BROWSEUI.@)
186 HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *info)
188 if (info->cbSize != sizeof(DLLVERSIONINFO)) FIXME("support DLLVERSIONINFO2\n");
190 /* this is what IE6 on Windows 98 reports */
191 info->dwMajorVersion = 6;
192 info->dwMinorVersion = 0;
193 info->dwBuildNumber = 2600;
194 info->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
199 /***********************************************************************
200 * DllGetClassObject (BROWSEUI.@)
202 HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *ppvOut)
207 if (!IsEqualIID(iid, &IID_IUnknown) && !IsEqualIID(iid, &IID_IClassFactory))
208 return E_NOINTERFACE;
210 for (i = 0; ClassesTable[i].clsid != NULL; i++)
211 if (IsEqualCLSID(ClassesTable[i].clsid, clsid)) {
212 return ClassFactory_Constructor(ClassesTable[i].ctor, ppvOut);
214 FIXME("CLSID %s not supported\n", debugstr_guid(clsid));
215 return CLASS_E_CLASSNOTAVAILABLE;