wined3d: Use the bo binding in wined3d_context_gl_map_bo_address().
[wine.git] / dlls / browseui / browseui_main.c
blob71981d7b7f299cf65b0e92bae06a8a78f6501008
1 /*
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
22 #include <stdarg.h>
23 #include <stdio.h>
25 #define COBJMACROS
27 #include "wine/debug.h"
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winreg.h"
31 #include "shlwapi.h"
32 #include "shlguid.h"
33 #include "rpcproxy.h"
35 #include "wine/heap.h"
36 #include "browseui.h"
38 #include "initguid.h"
39 DEFINE_GUID(CLSID_CompCatCacheDaemon, 0x8C7461EF, 0x2b13, 0x11d2, 0xbe, 0x35, 0x30, 0x78, 0x30, 0x2c, 0x20, 0x30);
41 WINE_DEFAULT_DEBUG_CHANNEL(browseui);
43 LONG BROWSEUI_refCount = 0;
45 HINSTANCE BROWSEUI_hinstance = 0;
47 typedef HRESULT (*LPFNCONSTRUCTOR)(IUnknown *pUnkOuter, IUnknown **ppvOut);
49 static const struct {
50 REFCLSID clsid;
51 LPFNCONSTRUCTOR ctor;
52 } ClassesTable[] = {
53 {&CLSID_ACLMulti, ACLMulti_Constructor},
54 {&CLSID_ProgressDialog, ProgressDialog_Constructor},
55 {&CLSID_CompCatCacheDaemon, CompCatCacheDaemon_Constructor},
56 {&CLSID_ACListISF, ACLShellSource_Constructor},
57 {NULL, NULL}
60 typedef struct tagClassFactory
62 IClassFactory IClassFactory_iface;
63 LONG ref;
64 LPFNCONSTRUCTOR ctor;
65 } ClassFactory;
67 static inline ClassFactory *impl_from_IClassFactory(IClassFactory *iface)
69 return CONTAINING_RECORD(iface, ClassFactory, IClassFactory_iface);
72 static void ClassFactory_Destructor(ClassFactory *This)
74 TRACE("Destroying class factory %p\n", This);
75 heap_free(This);
76 InterlockedDecrement(&BROWSEUI_refCount);
79 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppvOut)
81 *ppvOut = NULL;
82 if (IsEqualIID(riid, &IID_IClassFactory) || IsEqualIID(riid, &IID_IUnknown)) {
83 IClassFactory_AddRef(iface);
84 *ppvOut = iface;
85 return S_OK;
88 WARN("Unknown interface %s\n", debugstr_guid(riid));
89 return E_NOINTERFACE;
92 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
94 ClassFactory *This = impl_from_IClassFactory(iface);
95 return InterlockedIncrement(&This->ref);
98 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
100 ClassFactory *This = impl_from_IClassFactory(iface);
101 ULONG ret = InterlockedDecrement(&This->ref);
103 if (ret == 0)
104 ClassFactory_Destructor(This);
105 return ret;
108 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *punkOuter, REFIID iid, LPVOID *ppvOut)
110 ClassFactory *This = impl_from_IClassFactory(iface);
111 HRESULT ret;
112 IUnknown *obj;
114 TRACE("(%p, %p, %s, %p)\n", iface, punkOuter, debugstr_guid(iid), ppvOut);
115 ret = This->ctor(punkOuter, &obj);
116 if (FAILED(ret))
117 return ret;
118 ret = IUnknown_QueryInterface(obj, iid, ppvOut);
119 IUnknown_Release(obj);
120 return ret;
123 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
125 ClassFactory *This = impl_from_IClassFactory(iface);
127 TRACE("(%p)->(%x)\n", This, fLock);
129 if(fLock)
130 InterlockedIncrement(&BROWSEUI_refCount);
131 else
132 InterlockedDecrement(&BROWSEUI_refCount);
134 return S_OK;
137 static const IClassFactoryVtbl ClassFactoryVtbl = {
138 /* IUnknown */
139 ClassFactory_QueryInterface,
140 ClassFactory_AddRef,
141 ClassFactory_Release,
143 /* IClassFactory*/
144 ClassFactory_CreateInstance,
145 ClassFactory_LockServer
148 static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut)
150 ClassFactory *This = heap_alloc(sizeof(ClassFactory));
151 This->IClassFactory_iface.lpVtbl = &ClassFactoryVtbl;
152 This->ref = 1;
153 This->ctor = ctor;
154 *ppvOut = &This->IClassFactory_iface;
155 TRACE("Created class factory %p\n", This);
156 InterlockedIncrement(&BROWSEUI_refCount);
157 return S_OK;
160 /*************************************************************************
161 * BROWSEUI DllMain
163 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
165 TRACE("%p 0x%x %p\n", hinst, fdwReason, fImpLoad);
166 switch (fdwReason)
168 case DLL_WINE_PREATTACH:
169 return FALSE; /* prefer native version */
170 case DLL_PROCESS_ATTACH:
171 DisableThreadLibraryCalls(hinst);
172 BROWSEUI_hinstance = hinst;
173 break;
175 return TRUE;
178 /*************************************************************************
179 * DllCanUnloadNow (BROWSEUI.@)
181 HRESULT WINAPI DllCanUnloadNow(void)
183 return BROWSEUI_refCount ? S_FALSE : S_OK;
186 /***********************************************************************
187 * DllGetVersion (BROWSEUI.@)
189 HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *info)
191 if(info->cbSize == sizeof(DLLVERSIONINFO) ||
192 info->cbSize == sizeof(DLLVERSIONINFO2))
194 /* this is what IE6 on Windows 98 reports */
195 info->dwMajorVersion = 6;
196 info->dwMinorVersion = 0;
197 info->dwBuildNumber = 2600;
198 info->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
199 if(info->cbSize == sizeof(DLLVERSIONINFO2))
201 DLLVERSIONINFO2 *info2 = (DLLVERSIONINFO2*) info;
202 info2->dwFlags = 0;
203 info2->ullVersion = MAKEDLLVERULL(info->dwMajorVersion,
204 info->dwMinorVersion,
205 info->dwBuildNumber,
206 0); /* FIXME: correct hotfix number */
208 return S_OK;
211 WARN("wrong DLLVERSIONINFO size from app.\n");
212 return E_INVALIDARG;
215 /***********************************************************************
216 * DllGetClassObject (BROWSEUI.@)
218 HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *ppvOut)
220 int i;
222 *ppvOut = NULL;
223 if (!IsEqualIID(iid, &IID_IUnknown) && !IsEqualIID(iid, &IID_IClassFactory))
224 return E_NOINTERFACE;
226 for (i = 0; ClassesTable[i].clsid != NULL; i++)
227 if (IsEqualCLSID(ClassesTable[i].clsid, clsid)) {
228 return ClassFactory_Constructor(ClassesTable[i].ctor, ppvOut);
230 FIXME("CLSID %s not supported\n", debugstr_guid(clsid));
231 return CLASS_E_CLASSNOTAVAILABLE;
234 /***********************************************************************
235 * DllInstall (BROWSEUI.@)
237 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
239 FIXME("(%s, %s): stub\n", bInstall ? "TRUE" : "FALSE", debugstr_w(cmdline));
240 return S_OK;
243 /***********************************************************************
244 * DllRegisterServer (BROWSEUI.@)
246 HRESULT WINAPI DllRegisterServer(void)
248 return __wine_register_resources( BROWSEUI_hinstance );
251 /***********************************************************************
252 * DllUnregisterServer (BROWSEUI.@)
254 HRESULT WINAPI DllUnregisterServer(void)
256 return __wine_unregister_resources( BROWSEUI_hinstance );