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
},
53 {&CLSID_ProgressDialog
, ProgressDialog_Constructor
},
57 typedef struct tagClassFactory
59 const IClassFactoryVtbl
*vtbl
;
63 static const IClassFactoryVtbl ClassFactoryVtbl
;
65 static HRESULT
ClassFactory_Constructor(LPFNCONSTRUCTOR ctor
, LPVOID
*ppvOut
)
67 ClassFactory
*This
= CoTaskMemAlloc(sizeof(ClassFactory
));
68 This
->vtbl
= &ClassFactoryVtbl
;
71 *ppvOut
= (LPVOID
)This
;
72 TRACE("Created class factory %p\n", This
);
77 static void ClassFactory_Destructor(ClassFactory
*This
)
79 TRACE("Destroying class factory %p\n", This
);
84 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, LPVOID
*ppvOut
)
87 if (IsEqualIID(riid
, &IID_IClassFactory
) || IsEqualIID(riid
, &IID_IUnknown
)) {
88 IClassFactory_AddRef(iface
);
93 WARN("Unknown interface %s\n", debugstr_guid(riid
));
97 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
99 ClassFactory
*This
= (ClassFactory
*)iface
;
100 return InterlockedIncrement(&This
->ref
);
103 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
105 ClassFactory
*This
= (ClassFactory
*)iface
;
106 ULONG ret
= InterlockedDecrement(&This
->ref
);
109 ClassFactory_Destructor(This
);
113 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*punkOuter
, REFIID iid
, LPVOID
*ppvOut
)
115 ClassFactory
*This
= (ClassFactory
*)iface
;
119 TRACE("(%p, %p, %s, %p)\n", iface
, punkOuter
, debugstr_guid(iid
), ppvOut
);
120 ret
= This
->ctor(punkOuter
, &obj
);
123 ret
= IUnknown_QueryInterface(obj
, iid
, ppvOut
);
124 IUnknown_Release(obj
);
128 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL fLock
)
130 ClassFactory
*This
= (ClassFactory
*)iface
;
132 TRACE("(%p)->(%x)\n", This
, fLock
);
135 InterlockedIncrement(&BROWSEUI_refCount
);
137 InterlockedDecrement(&BROWSEUI_refCount
);
142 static const IClassFactoryVtbl ClassFactoryVtbl
= {
144 ClassFactory_QueryInterface
,
146 ClassFactory_Release
,
149 ClassFactory_CreateInstance
,
150 ClassFactory_LockServer
153 /*************************************************************************
156 BOOL WINAPI
DllMain(HINSTANCE hinst
, DWORD fdwReason
, LPVOID fImpLoad
)
158 TRACE("%p 0x%x %p\n", hinst
, fdwReason
, fImpLoad
);
161 case DLL_WINE_PREATTACH
:
162 return FALSE
; /* prefer native version */
163 case DLL_PROCESS_ATTACH
:
164 DisableThreadLibraryCalls(hinst
);
165 BROWSEUI_hinstance
= hinst
;
171 /*************************************************************************
172 * DllCanUnloadNow (BROWSEUI.@)
174 HRESULT WINAPI
DllCanUnloadNow(void)
176 return BROWSEUI_refCount
? S_FALSE
: S_OK
;
179 /***********************************************************************
180 * DllGetVersion (BROWSEUI.@)
182 HRESULT WINAPI
DllGetVersion(DLLVERSIONINFO
*info
)
184 if (info
->cbSize
!= sizeof(DLLVERSIONINFO
)) FIXME("support DLLVERSIONINFO2\n");
186 /* this is what IE6 on Windows 98 reports */
187 info
->dwMajorVersion
= 6;
188 info
->dwMinorVersion
= 0;
189 info
->dwBuildNumber
= 2600;
190 info
->dwPlatformID
= DLLVER_PLATFORM_WINDOWS
;
195 /***********************************************************************
196 * DllGetClassObject (BROWSEUI.@)
198 HRESULT WINAPI
DllGetClassObject(REFCLSID clsid
, REFIID iid
, LPVOID
*ppvOut
)
203 if (!IsEqualIID(iid
, &IID_IUnknown
) && !IsEqualIID(iid
, &IID_IClassFactory
))
204 return E_NOINTERFACE
;
206 for (i
= 0; ClassesTable
[i
].clsid
!= NULL
; i
++)
207 if (IsEqualCLSID(ClassesTable
[i
].clsid
, clsid
)) {
208 return ClassFactory_Constructor(ClassesTable
[i
].ctor
, ppvOut
);
210 FIXME("CLSID %s not supported\n", debugstr_guid(clsid
));
211 return CLASS_E_CLASSNOTAVAILABLE
;