d3d8: Do not specify WINED3D_TEXTURE_CREATE_MAPPABLE in d3d8_device_CreateDepthStenci...
[wine.git] / dlls / browseui / browseui_main.c
blob2e31b37fc8541c68a942231a157638e606f662d7
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 "config.h"
24 #include <stdarg.h>
25 #include <stdio.h>
27 #define COBJMACROS
29 #include "wine/debug.h"
30 #include "windef.h"
31 #include "winbase.h"
32 #include "winreg.h"
33 #include "shlwapi.h"
34 #include "shlguid.h"
35 #include "rpcproxy.h"
37 #include "wine/heap.h"
38 #include "browseui.h"
40 #include "initguid.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 (*LPFNCONSTRUCTOR)(IUnknown *pUnkOuter, IUnknown **ppvOut);
51 static const struct {
52 REFCLSID clsid;
53 LPFNCONSTRUCTOR ctor;
54 } ClassesTable[] = {
55 {&CLSID_ACLMulti, ACLMulti_Constructor},
56 {&CLSID_ProgressDialog, ProgressDialog_Constructor},
57 {&CLSID_CompCatCacheDaemon, CompCatCacheDaemon_Constructor},
58 {&CLSID_ACListISF, ACLShellSource_Constructor},
59 {NULL, NULL}
62 typedef struct tagClassFactory
64 IClassFactory IClassFactory_iface;
65 LONG ref;
66 LPFNCONSTRUCTOR ctor;
67 } ClassFactory;
69 static inline ClassFactory *impl_from_IClassFactory(IClassFactory *iface)
71 return CONTAINING_RECORD(iface, ClassFactory, IClassFactory_iface);
74 static void ClassFactory_Destructor(ClassFactory *This)
76 TRACE("Destroying class factory %p\n", This);
77 heap_free(This);
78 InterlockedDecrement(&BROWSEUI_refCount);
81 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppvOut)
83 *ppvOut = NULL;
84 if (IsEqualIID(riid, &IID_IClassFactory) || IsEqualIID(riid, &IID_IUnknown)) {
85 IClassFactory_AddRef(iface);
86 *ppvOut = iface;
87 return S_OK;
90 WARN("Unknown interface %s\n", debugstr_guid(riid));
91 return E_NOINTERFACE;
94 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
96 ClassFactory *This = impl_from_IClassFactory(iface);
97 return InterlockedIncrement(&This->ref);
100 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
102 ClassFactory *This = impl_from_IClassFactory(iface);
103 ULONG ret = InterlockedDecrement(&This->ref);
105 if (ret == 0)
106 ClassFactory_Destructor(This);
107 return ret;
110 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *punkOuter, REFIID iid, LPVOID *ppvOut)
112 ClassFactory *This = impl_from_IClassFactory(iface);
113 HRESULT ret;
114 IUnknown *obj;
116 TRACE("(%p, %p, %s, %p)\n", iface, punkOuter, debugstr_guid(iid), ppvOut);
117 ret = This->ctor(punkOuter, &obj);
118 if (FAILED(ret))
119 return ret;
120 ret = IUnknown_QueryInterface(obj, iid, ppvOut);
121 IUnknown_Release(obj);
122 return ret;
125 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
127 ClassFactory *This = impl_from_IClassFactory(iface);
129 TRACE("(%p)->(%x)\n", This, fLock);
131 if(fLock)
132 InterlockedIncrement(&BROWSEUI_refCount);
133 else
134 InterlockedDecrement(&BROWSEUI_refCount);
136 return S_OK;
139 static const IClassFactoryVtbl ClassFactoryVtbl = {
140 /* IUnknown */
141 ClassFactory_QueryInterface,
142 ClassFactory_AddRef,
143 ClassFactory_Release,
145 /* IClassFactory*/
146 ClassFactory_CreateInstance,
147 ClassFactory_LockServer
150 static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut)
152 ClassFactory *This = heap_alloc(sizeof(ClassFactory));
153 This->IClassFactory_iface.lpVtbl = &ClassFactoryVtbl;
154 This->ref = 1;
155 This->ctor = ctor;
156 *ppvOut = &This->IClassFactory_iface;
157 TRACE("Created class factory %p\n", This);
158 InterlockedIncrement(&BROWSEUI_refCount);
159 return S_OK;
162 /*************************************************************************
163 * BROWSEUI DllMain
165 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
167 TRACE("%p 0x%x %p\n", hinst, fdwReason, fImpLoad);
168 switch (fdwReason)
170 case DLL_WINE_PREATTACH:
171 return FALSE; /* prefer native version */
172 case DLL_PROCESS_ATTACH:
173 DisableThreadLibraryCalls(hinst);
174 BROWSEUI_hinstance = hinst;
175 break;
177 return TRUE;
180 /*************************************************************************
181 * DllCanUnloadNow (BROWSEUI.@)
183 HRESULT WINAPI DllCanUnloadNow(void)
185 return BROWSEUI_refCount ? S_FALSE : S_OK;
188 /***********************************************************************
189 * DllGetVersion (BROWSEUI.@)
191 HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *info)
193 if(info->cbSize == sizeof(DLLVERSIONINFO) ||
194 info->cbSize == sizeof(DLLVERSIONINFO2))
196 /* this is what IE6 on Windows 98 reports */
197 info->dwMajorVersion = 6;
198 info->dwMinorVersion = 0;
199 info->dwBuildNumber = 2600;
200 info->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
201 if(info->cbSize == sizeof(DLLVERSIONINFO2))
203 DLLVERSIONINFO2 *info2 = (DLLVERSIONINFO2*) info;
204 info2->dwFlags = 0;
205 info2->ullVersion = MAKEDLLVERULL(info->dwMajorVersion,
206 info->dwMinorVersion,
207 info->dwBuildNumber,
208 0); /* FIXME: correct hotfix number */
210 return S_OK;
213 WARN("wrong DLLVERSIONINFO size from app.\n");
214 return E_INVALIDARG;
217 /***********************************************************************
218 * DllGetClassObject (BROWSEUI.@)
220 HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *ppvOut)
222 int i;
224 *ppvOut = NULL;
225 if (!IsEqualIID(iid, &IID_IUnknown) && !IsEqualIID(iid, &IID_IClassFactory))
226 return E_NOINTERFACE;
228 for (i = 0; ClassesTable[i].clsid != NULL; i++)
229 if (IsEqualCLSID(ClassesTable[i].clsid, clsid)) {
230 return ClassFactory_Constructor(ClassesTable[i].ctor, ppvOut);
232 FIXME("CLSID %s not supported\n", debugstr_guid(clsid));
233 return CLASS_E_CLASSNOTAVAILABLE;
236 /***********************************************************************
237 * DllInstall (BROWSEUI.@)
239 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
241 FIXME("(%s, %s): stub\n", bInstall ? "TRUE" : "FALSE", debugstr_w(cmdline));
242 return S_OK;
245 /***********************************************************************
246 * DllRegisterServer (BROWSEUI.@)
248 HRESULT WINAPI DllRegisterServer(void)
250 return __wine_register_resources( BROWSEUI_hinstance );
253 /***********************************************************************
254 * DllUnregisterServer (BROWSEUI.@)
256 HRESULT WINAPI DllUnregisterServer(void)
258 return __wine_unregister_resources( BROWSEUI_hinstance );