4 * Copyright 1998 Marcus Meissner
5 * Copyright 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
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
24 #include "shell32_version.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
28 /**************************************************************************
29 * Default ClassFactory types
31 typedef HRESULT (CALLBACK
*LPFNCREATEINSTANCE
)(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppvObject
);
32 HRESULT
IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, const IID
*riidInst
, IClassFactory
**theFactory
);
35 /**************************************************************************
36 * Default ClassFactory Implementation
38 * SHCreateDefClassObject
41 * Helper function for dlls without their own classfactory.
42 * A generic classfactory is returned.
43 * When the CreateInstance of the cf is called the callback is executed.
47 public CComObjectRootEx
<CComMultiThreadModelNoCS
>,
52 LPFNCREATEINSTANCE lpfnCI
;
54 LONG
*pcRefDll
; /* pointer to refcounter in external dll (ugrrr...) */
57 HRESULT
Initialize(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, const IID
*riidInstx
);
60 virtual HRESULT WINAPI
CreateInstance(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
);
61 virtual HRESULT WINAPI
LockServer(BOOL fLock
);
63 BEGIN_COM_MAP(IDefClFImpl
)
64 COM_INTERFACE_ENTRY_IID(IID_IClassFactory
, IClassFactory
)
68 IDefClFImpl::IDefClFImpl()
76 HRESULT
IDefClFImpl::Initialize(LPFNCREATEINSTANCE lpfnCIx
, PLONG pcRefDllx
, const IID
*riidInstx
)
83 InterlockedIncrement(pcRefDll
);
85 TRACE("(%p)%s\n", this, shdebugstr_guid(riidInst
));
89 /******************************************************************************
90 * IDefClF_fnCreateInstance
92 HRESULT WINAPI
IDefClFImpl::CreateInstance(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
)
94 TRACE("%p->(%p,%s,%p)\n", this, pUnkOuter
, shdebugstr_guid(&riid
), ppvObject
);
98 if (riidInst
== NULL
|| IsEqualCLSID(riid
, *riidInst
) || IsEqualCLSID(riid
, IID_IUnknown
))
100 return lpfnCI(pUnkOuter
, riid
, ppvObject
);
103 ERR("unknown IID requested %s\n", shdebugstr_guid(&riid
));
104 return E_NOINTERFACE
;
107 /******************************************************************************
108 * IDefClF_fnLockServer
110 HRESULT WINAPI
IDefClFImpl::LockServer(BOOL fLock
)
112 TRACE("%p->(0x%x), not implemented\n", this, fLock
);
116 /**************************************************************************
117 * IDefClF_fnConstructor
120 HRESULT
IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, const IID
*riidInst
, IClassFactory
**theFactory
)
122 return ShellObjectCreatorInit
<IDefClFImpl
>(lpfnCI
, pcRefDll
, riidInst
, IID_IClassFactory
, theFactory
);
125 /******************************************************************************
126 * SHCreateDefClassObject [SHELL32.70]
128 HRESULT WINAPI
SHCreateDefClassObject(
131 LPFNCREATEINSTANCE lpfnCI
, /* [in] create instance callback entry */
132 LPDWORD pcRefDll
, /* [in/out] ref count of the dll */
133 REFIID riidInst
) /* [in] optional interface to the instance */
138 TRACE("%s %p %p %p %s\n", shdebugstr_guid(&riid
), ppv
, lpfnCI
, pcRefDll
, shdebugstr_guid(&riidInst
));
140 if (!IsEqualCLSID(riid
, IID_IClassFactory
))
141 return E_NOINTERFACE
;
142 hResult
= IDefClF_fnConstructor(lpfnCI
, (PLONG
)pcRefDll
, &riidInst
, &pcf
);
149 /**************************************************************************
152 class CStartMenuDummy
:
153 public CComCoClass
<CStartMenuDummy
, &CLSID_StartMenu
>,
154 public CComObjectRootEx
<CComMultiThreadModelNoCS
>
158 virtual ~CStartMenuDummy();
161 DECLARE_REGISTRY_RESOURCEID(IDR_STARTMENU
)
166 static STDMETHODIMP
CreateInstance(void *pv
, REFIID riid
, LPVOID
*ppv
)
172 return CLASS_E_NOAGGREGATION
;
173 return CStartMenu_Constructor(riid
, ppv
);
178 /**************************************************************************
181 class CShell32Module
: public CComModule
186 CComCreatorCentralInstance
< ATL::CComObject
< CDrivesFolder
> >::Term();
187 CComCreatorCentralInstance
< ATL::CComObject
< CDesktopFolder
> >::Term();
193 BEGIN_OBJECT_MAP(ObjectMap
)
194 OBJECT_ENTRY(CLSID_ShellFSFolder
, CFSFolder
)
195 OBJECT_ENTRY(CLSID_MyComputer
, CDrivesFolder
)
196 OBJECT_ENTRY(CLSID_ShellDesktop
, CDesktopFolder
)
197 OBJECT_ENTRY(CLSID_ShellItem
, CShellItem
)
198 OBJECT_ENTRY(CLSID_ShellLink
, CShellLink
)
199 OBJECT_ENTRY(CLSID_Shell
, CShell
)
200 OBJECT_ENTRY(CLSID_DragDropHelper
, CDropTargetHelper
)
201 OBJECT_ENTRY(CLSID_ControlPanel
, CControlPanelFolder
)
202 OBJECT_ENTRY(CLSID_MyDocuments
, CMyDocsFolder
)
203 OBJECT_ENTRY(CLSID_NetworkPlaces
, CNetFolder
)
204 OBJECT_ENTRY(CLSID_FontsFolderShortcut
, CFontsFolder
)
205 OBJECT_ENTRY(CLSID_Printers
, CPrinterFolder
)
206 OBJECT_ENTRY(CLSID_AdminFolderShortcut
, CAdminToolsFolder
)
207 OBJECT_ENTRY(CLSID_RecycleBin
, CRecycleBin
)
208 OBJECT_ENTRY(CLSID_OpenWithMenu
, COpenWithMenu
)
209 OBJECT_ENTRY(CLSID_NewMenu
, CNewMenu
)
210 OBJECT_ENTRY(CLSID_StartMenu
, CStartMenuDummy
)
211 OBJECT_ENTRY(CLSID_MenuBandSite
, CMenuSite
)
212 OBJECT_ENTRY(CLSID_MenuBand
, CMenuBand
)
213 OBJECT_ENTRY(CLSID_MenuDeskBar
, CMenuDeskBar
)
214 OBJECT_ENTRY(CLSID_MergedFolder
, CMergedFolder
)
215 OBJECT_ENTRY(CLSID_RebarBandSite
, CBandSite
)
216 OBJECT_ENTRY(CLSID_ExeDropHandler
, CExeDropHandler
)
217 OBJECT_ENTRY(CLSID_QueryAssociations
, CQueryAssociations
)
220 CShell32Module gModule
;
223 /***********************************************************************
224 * DllGetVersion [SHELL32.@]
226 * Retrieves version information of the 'SHELL32.DLL'
229 * pdvi [O] pointer to version information structure.
233 * Failure: E_INVALIDARG
236 * Returns version of a shell32.dll from IE4.01 SP1.
239 STDAPI
DllGetVersion(DLLVERSIONINFO
*pdvi
)
241 /* FIXME: shouldn't these values come from the version resource? */
242 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO
) ||
243 pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
245 pdvi
->dwMajorVersion
= WINE_FILEVERSION_MAJOR
;
246 pdvi
->dwMinorVersion
= WINE_FILEVERSION_MINOR
;
247 pdvi
->dwBuildNumber
= WINE_FILEVERSION_BUILD
;
248 pdvi
->dwPlatformID
= WINE_FILEVERSION_PLATFORMID
;
249 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
251 DLLVERSIONINFO2
*pdvi2
= (DLLVERSIONINFO2
*)pdvi
;
254 pdvi2
->ullVersion
= MAKEDLLVERULL(WINE_FILEVERSION_MAJOR
,
255 WINE_FILEVERSION_MINOR
,
256 WINE_FILEVERSION_BUILD
,
257 WINE_FILEVERSION_PLATFORMID
);
259 TRACE("%u.%u.%u.%u\n",
260 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
261 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
266 WARN("wrong DLLVERSIONINFO size from app\n");
271 /*************************************************************************
272 * global variables of the shell32.dll
273 * all are once per process
276 HINSTANCE shell32_hInstance
;
278 void *operator new (size_t, void *buf
)
283 /*************************************************************************
287 * calling oleinitialize here breaks sone apps.
289 STDAPI_(BOOL
) DllMain(HINSTANCE hInstance
, DWORD dwReason
, LPVOID fImpLoad
)
291 TRACE("%p 0x%x %p\n", hInstance
, dwReason
, fImpLoad
);
292 if (dwReason
== DLL_PROCESS_ATTACH
)
294 shell32_hInstance
= hInstance
;
295 gModule
.Init(ObjectMap
, hInstance
, &LIBID_Shell32
);
297 DisableThreadLibraryCalls (hInstance
);
299 /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
300 GetModuleFileNameW(hInstance
, swShell32Name
, MAX_PATH
);
301 swShell32Name
[MAX_PATH
- 1] = '\0';
303 /* Initialize comctl32 */
304 INITCOMMONCONTROLSEX InitCtrls
;
305 InitCtrls
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
306 InitCtrls
.dwICC
= ICC_WIN95_CLASSES
| ICC_DATE_CLASSES
| ICC_USEREX_CLASSES
;
307 InitCommonControlsEx(&InitCtrls
);
310 InitChangeNotifications();
313 else if (dwReason
== DLL_PROCESS_DETACH
)
315 shell32_hInstance
= NULL
;
317 FreeChangeNotifications();
323 /***********************************************************************
324 * DllCanUnloadNow (SHELL32.@)
326 STDAPI
DllCanUnloadNow()
328 return gModule
.DllCanUnloadNow();
331 /*************************************************************************
332 * DllGetClassObject [SHELL32.@]
333 * SHDllGetClassObject [SHELL32.128]
335 STDAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
339 TRACE("CLSID:%s,IID:%s\n", shdebugstr_guid(&rclsid
), shdebugstr_guid(&riid
));
341 hResult
= gModule
.DllGetClassObject(rclsid
, riid
, ppv
);
342 TRACE("-- pointer to class factory: %p\n", *ppv
);
346 /***********************************************************************
347 * DllRegisterServer (SHELL32.@)
349 STDAPI
DllRegisterServer()
353 hr
= gModule
.DllRegisterServer(FALSE
);
357 hr
= gModule
.UpdateRegistryFromResource(IDR_FOLDEROPTIONS
, TRUE
, NULL
);
361 hr
= SHELL_RegisterShellFolders();
368 /***********************************************************************
369 * DllUnregisterServer (SHELL32.@)
371 STDAPI
DllUnregisterServer()
375 hr
= gModule
.DllUnregisterServer(FALSE
);
379 hr
= gModule
.UpdateRegistryFromResource(IDR_FOLDEROPTIONS
, FALSE
, NULL
);
386 /*************************************************************************
387 * DllInstall [SHELL32.@]
391 * BOOL bInstall - TRUE for install, FALSE for uninstall
392 * LPCWSTR pszCmdLine - command line (unused by shell32?)
395 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
397 FIXME("%s %s: stub\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
398 return S_OK
; /* indicate success */