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
);
33 AddCommasW(DWORD lValue
, LPWSTR lpNumber
)
35 WCHAR szValue
[MAX_PATH
], szSeparator
[8 + 1];
38 GetLocaleInfoW(LOCALE_USER_DEFAULT
,
41 _countof(szSeparator
));
43 numFormat
.NumDigits
= 0;
44 numFormat
.LeadingZero
= 0;
45 numFormat
.Grouping
= 3; // FIXME! Use GetLocaleInfoW with LOCALE_SGROUPING and interpret the result.
46 numFormat
.lpDecimalSep
= szSeparator
;
47 numFormat
.lpThousandSep
= szSeparator
;
48 numFormat
.NegativeOrder
= 0;
50 swprintf(szValue
, L
"%lu", lValue
);
52 if (GetNumberFormatW(LOCALE_USER_DEFAULT
,
62 wcscpy(lpNumber
, szValue
);
66 /**************************************************************************
67 * Default ClassFactory types
69 typedef HRESULT (CALLBACK
*LPFNCREATEINSTANCE
)(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppvObject
);
70 HRESULT
IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, const IID
*riidInst
, IClassFactory
**theFactory
);
73 /**************************************************************************
74 * Default ClassFactory Implementation
76 * SHCreateDefClassObject
79 * Helper function for dlls without their own classfactory.
80 * A generic classfactory is returned.
81 * When the CreateInstance of the cf is called the callback is executed.
85 public CComObjectRootEx
<CComMultiThreadModelNoCS
>,
90 LPFNCREATEINSTANCE lpfnCI
;
92 LONG
*pcRefDll
; /* pointer to refcounter in external dll (ugrrr...) */
95 HRESULT
Initialize(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, const IID
*riidInstx
);
98 virtual HRESULT WINAPI
CreateInstance(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
);
99 virtual HRESULT WINAPI
LockServer(BOOL fLock
);
101 BEGIN_COM_MAP(IDefClFImpl
)
102 COM_INTERFACE_ENTRY_IID(IID_IClassFactory
, IClassFactory
)
106 IDefClFImpl::IDefClFImpl()
114 HRESULT
IDefClFImpl::Initialize(LPFNCREATEINSTANCE lpfnCIx
, PLONG pcRefDllx
, const IID
*riidInstx
)
117 riidInst
= riidInstx
;
118 pcRefDll
= pcRefDllx
;
121 InterlockedIncrement(pcRefDll
);
123 TRACE("(%p)%s\n", this, shdebugstr_guid(riidInst
));
127 /******************************************************************************
128 * IDefClF_fnCreateInstance
130 HRESULT WINAPI
IDefClFImpl::CreateInstance(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
)
132 TRACE("%p->(%p,%s,%p)\n", this, pUnkOuter
, shdebugstr_guid(&riid
), ppvObject
);
136 if (riidInst
== NULL
|| IsEqualCLSID(riid
, *riidInst
) || IsEqualCLSID(riid
, IID_IUnknown
))
138 return lpfnCI(pUnkOuter
, riid
, ppvObject
);
141 ERR("unknown IID requested %s\n", shdebugstr_guid(&riid
));
142 return E_NOINTERFACE
;
145 /******************************************************************************
146 * IDefClF_fnLockServer
148 HRESULT WINAPI
IDefClFImpl::LockServer(BOOL fLock
)
150 TRACE("%p->(0x%x), not implemented\n", this, fLock
);
154 /**************************************************************************
155 * IDefClF_fnConstructor
158 HRESULT
IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, const IID
*riidInst
, IClassFactory
**theFactory
)
160 return ShellObjectCreatorInit
<IDefClFImpl
>(lpfnCI
, pcRefDll
, riidInst
, IID_PPV_ARG(IClassFactory
, theFactory
));
163 /******************************************************************************
164 * SHCreateDefClassObject [SHELL32.70]
166 HRESULT WINAPI
SHCreateDefClassObject(
169 LPFNCREATEINSTANCE lpfnCI
, /* [in] create instance callback entry */
170 LPDWORD pcRefDll
, /* [in/out] ref count of the dll */
171 REFIID riidInst
) /* [in] optional interface to the instance */
176 TRACE("%s %p %p %p %s\n", shdebugstr_guid(&riid
), ppv
, lpfnCI
, pcRefDll
, shdebugstr_guid(&riidInst
));
178 if (!IsEqualCLSID(riid
, IID_IClassFactory
))
179 return E_NOINTERFACE
;
180 hResult
= IDefClF_fnConstructor(lpfnCI
, (PLONG
)pcRefDll
, &riidInst
, &pcf
);
187 /**************************************************************************
190 class CStartMenuDummy
:
191 public CComCoClass
<CStartMenuDummy
, &CLSID_StartMenu
>,
192 public CComObjectRootEx
<CComMultiThreadModelNoCS
>
196 virtual ~CStartMenuDummy();
199 DECLARE_REGISTRY_RESOURCEID(IDR_STARTMENU
)
204 static STDMETHODIMP
CreateInstance(void *pv
, REFIID riid
, LPVOID
*ppv
)
210 return CLASS_E_NOAGGREGATION
;
211 return CStartMenu_Constructor(riid
, ppv
);
216 /**************************************************************************
219 class CShell32Module
: public CComModule
224 CComCreatorCentralInstance
< ATL::CComObject
< CDrivesFolder
> >::Term();
225 CComCreatorCentralInstance
< ATL::CComObject
< CDesktopFolder
> >::Term();
231 BEGIN_OBJECT_MAP(ObjectMap
)
232 OBJECT_ENTRY(CLSID_ShellFSFolder
, CFSFolder
)
233 OBJECT_ENTRY(CLSID_MyComputer
, CDrivesFolder
)
234 OBJECT_ENTRY(CLSID_ShellDesktop
, CDesktopFolder
)
235 OBJECT_ENTRY(CLSID_ShellItem
, CShellItem
)
236 OBJECT_ENTRY(CLSID_ShellLink
, CShellLink
)
237 OBJECT_ENTRY(CLSID_Shell
, CShellDispatch
)
238 OBJECT_ENTRY(CLSID_DragDropHelper
, CDropTargetHelper
)
239 OBJECT_ENTRY(CLSID_ControlPanel
, CControlPanelFolder
)
240 OBJECT_ENTRY(CLSID_MyDocuments
, CMyDocsFolder
)
241 OBJECT_ENTRY(CLSID_NetworkPlaces
, CNetFolder
)
242 OBJECT_ENTRY(CLSID_FontsFolderShortcut
, CFontsFolder
)
243 OBJECT_ENTRY(CLSID_Printers
, CPrinterFolder
)
244 OBJECT_ENTRY(CLSID_AdminFolderShortcut
, CAdminToolsFolder
)
245 OBJECT_ENTRY(CLSID_ShellFldSetExt
, CFolderOptions
)
246 OBJECT_ENTRY(CLSID_RecycleBin
, CRecycleBin
)
247 OBJECT_ENTRY(CLSID_OpenWithMenu
, COpenWithMenu
)
248 OBJECT_ENTRY(CLSID_NewMenu
, CNewMenu
)
249 OBJECT_ENTRY(CLSID_StartMenu
, CStartMenuDummy
)
250 OBJECT_ENTRY(CLSID_MenuBandSite
, CMenuSite
)
251 OBJECT_ENTRY(CLSID_MenuBand
, CMenuBand
)
252 OBJECT_ENTRY(CLSID_MenuDeskBar
, CMenuDeskBar
)
253 OBJECT_ENTRY(CLSID_MergedFolder
, CMergedFolder
)
254 OBJECT_ENTRY(CLSID_ExeDropHandler
, CExeDropHandler
)
255 OBJECT_ENTRY(CLSID_QueryAssociations
, CQueryAssociations
)
258 CShell32Module gModule
;
261 /***********************************************************************
262 * DllGetVersion [SHELL32.@]
264 * Retrieves version information of the 'SHELL32.DLL'
267 * pdvi [O] pointer to version information structure.
271 * Failure: E_INVALIDARG
274 * Returns version of a shell32.dll from IE4.01 SP1.
277 STDAPI
DllGetVersion(DLLVERSIONINFO
*pdvi
)
279 /* FIXME: shouldn't these values come from the version resource? */
280 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO
) ||
281 pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
283 pdvi
->dwMajorVersion
= WINE_FILEVERSION_MAJOR
;
284 pdvi
->dwMinorVersion
= WINE_FILEVERSION_MINOR
;
285 pdvi
->dwBuildNumber
= WINE_FILEVERSION_BUILD
;
286 pdvi
->dwPlatformID
= WINE_FILEVERSION_PLATFORMID
;
287 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
289 DLLVERSIONINFO2
*pdvi2
= (DLLVERSIONINFO2
*)pdvi
;
292 pdvi2
->ullVersion
= MAKEDLLVERULL(WINE_FILEVERSION_MAJOR
,
293 WINE_FILEVERSION_MINOR
,
294 WINE_FILEVERSION_BUILD
,
295 WINE_FILEVERSION_PLATFORMID
);
297 TRACE("%u.%u.%u.%u\n",
298 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
299 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
304 WARN("wrong DLLVERSIONINFO size from app\n");
309 /*************************************************************************
310 * global variables of the shell32.dll
311 * all are once per process
314 HINSTANCE shell32_hInstance
;
316 void *operator new (size_t, void *buf
)
321 /*************************************************************************
325 * calling oleinitialize here breaks sone apps.
327 STDAPI_(BOOL
) DllMain(HINSTANCE hInstance
, DWORD dwReason
, LPVOID fImpLoad
)
329 TRACE("%p 0x%x %p\n", hInstance
, dwReason
, fImpLoad
);
330 if (dwReason
== DLL_PROCESS_ATTACH
)
332 shell32_hInstance
= hInstance
;
333 gModule
.Init(ObjectMap
, hInstance
, &LIBID_Shell32
);
335 DisableThreadLibraryCalls (hInstance
);
337 /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
338 GetModuleFileNameW(hInstance
, swShell32Name
, MAX_PATH
);
339 swShell32Name
[MAX_PATH
- 1] = '\0';
341 /* Initialize comctl32 */
342 INITCOMMONCONTROLSEX InitCtrls
;
343 InitCtrls
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
344 InitCtrls
.dwICC
= ICC_WIN95_CLASSES
| ICC_DATE_CLASSES
| ICC_USEREX_CLASSES
;
345 InitCommonControlsEx(&InitCtrls
);
347 /* Bad idea, initialization in DllMain! */
348 InitChangeNotifications();
350 else if (dwReason
== DLL_PROCESS_DETACH
)
352 shell32_hInstance
= NULL
;
354 FreeChangeNotifications();
360 /***********************************************************************
361 * DllCanUnloadNow (SHELL32.@)
363 STDAPI
DllCanUnloadNow()
365 return gModule
.DllCanUnloadNow();
368 /*************************************************************************
369 * DllGetClassObject [SHELL32.@]
370 * SHDllGetClassObject [SHELL32.128]
372 STDAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
376 TRACE("CLSID:%s,IID:%s\n", shdebugstr_guid(&rclsid
), shdebugstr_guid(&riid
));
378 hResult
= gModule
.DllGetClassObject(rclsid
, riid
, ppv
);
379 TRACE("-- pointer to class factory: %p\n", *ppv
);
383 /***********************************************************************
384 * DllRegisterServer (SHELL32.@)
386 STDAPI
DllRegisterServer()
390 hr
= gModule
.DllRegisterServer(TRUE
);
394 hr
= gModule
.UpdateRegistryFromResource(IDR_FOLDEROPTIONS
, TRUE
, NULL
);
398 hr
= SHELL_RegisterShellFolders();
405 /***********************************************************************
406 * DllUnregisterServer (SHELL32.@)
408 STDAPI
DllUnregisterServer()
412 hr
= gModule
.DllUnregisterServer(TRUE
);
416 hr
= gModule
.UpdateRegistryFromResource(IDR_FOLDEROPTIONS
, FALSE
, NULL
);
423 /*************************************************************************
424 * DllInstall [SHELL32.@]
428 * BOOL bInstall - TRUE for install, FALSE for uninstall
429 * LPCWSTR pszCmdLine - command line (unused by shell32?)
432 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
434 FIXME("%s %s: stub\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
435 return S_OK
; /* indicate success */