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
= 0; // 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
"%llu", lValue
);
51 //_ultow(lValue, szValue, 10);
53 if (GetNumberFormatW(LOCALE_USER_DEFAULT
,
58 wcslen(lpNumber
)) != 0)
63 wcscpy(lpNumber
, szValue
);
67 /**************************************************************************
68 * Default ClassFactory types
70 typedef HRESULT (CALLBACK
*LPFNCREATEINSTANCE
)(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppvObject
);
71 HRESULT
IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, const IID
*riidInst
, IClassFactory
**theFactory
);
74 /**************************************************************************
75 * Default ClassFactory Implementation
77 * SHCreateDefClassObject
80 * Helper function for dlls without their own classfactory.
81 * A generic classfactory is returned.
82 * When the CreateInstance of the cf is called the callback is executed.
86 public CComObjectRootEx
<CComMultiThreadModelNoCS
>,
91 LPFNCREATEINSTANCE lpfnCI
;
93 LONG
*pcRefDll
; /* pointer to refcounter in external dll (ugrrr...) */
96 HRESULT
Initialize(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, const IID
*riidInstx
);
99 virtual HRESULT WINAPI
CreateInstance(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
);
100 virtual HRESULT WINAPI
LockServer(BOOL fLock
);
102 BEGIN_COM_MAP(IDefClFImpl
)
103 COM_INTERFACE_ENTRY_IID(IID_IClassFactory
, IClassFactory
)
107 IDefClFImpl::IDefClFImpl()
115 HRESULT
IDefClFImpl::Initialize(LPFNCREATEINSTANCE lpfnCIx
, PLONG pcRefDllx
, const IID
*riidInstx
)
118 riidInst
= riidInstx
;
119 pcRefDll
= pcRefDllx
;
122 InterlockedIncrement(pcRefDll
);
124 TRACE("(%p)%s\n", this, shdebugstr_guid(riidInst
));
128 /******************************************************************************
129 * IDefClF_fnCreateInstance
131 HRESULT WINAPI
IDefClFImpl::CreateInstance(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
)
133 TRACE("%p->(%p,%s,%p)\n", this, pUnkOuter
, shdebugstr_guid(&riid
), ppvObject
);
137 if (riidInst
== NULL
|| IsEqualCLSID(riid
, *riidInst
) || IsEqualCLSID(riid
, IID_IUnknown
))
139 return lpfnCI(pUnkOuter
, riid
, ppvObject
);
142 ERR("unknown IID requested %s\n", shdebugstr_guid(&riid
));
143 return E_NOINTERFACE
;
146 /******************************************************************************
147 * IDefClF_fnLockServer
149 HRESULT WINAPI
IDefClFImpl::LockServer(BOOL fLock
)
151 TRACE("%p->(0x%x), not implemented\n", this, fLock
);
155 /**************************************************************************
156 * IDefClF_fnConstructor
159 HRESULT
IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, const IID
*riidInst
, IClassFactory
**theFactory
)
161 return ShellObjectCreatorInit
<IDefClFImpl
>(lpfnCI
, pcRefDll
, riidInst
, IID_IClassFactory
, theFactory
);
164 /******************************************************************************
165 * SHCreateDefClassObject [SHELL32.70]
167 HRESULT WINAPI
SHCreateDefClassObject(
170 LPFNCREATEINSTANCE lpfnCI
, /* [in] create instance callback entry */
171 LPDWORD pcRefDll
, /* [in/out] ref count of the dll */
172 REFIID riidInst
) /* [in] optional interface to the instance */
177 TRACE("%s %p %p %p %s\n", shdebugstr_guid(&riid
), ppv
, lpfnCI
, pcRefDll
, shdebugstr_guid(&riidInst
));
179 if (!IsEqualCLSID(riid
, IID_IClassFactory
))
180 return E_NOINTERFACE
;
181 hResult
= IDefClF_fnConstructor(lpfnCI
, (PLONG
)pcRefDll
, &riidInst
, &pcf
);
188 /**************************************************************************
191 class CStartMenuDummy
:
192 public CComCoClass
<CStartMenuDummy
, &CLSID_StartMenu
>,
193 public CComObjectRootEx
<CComMultiThreadModelNoCS
>
197 virtual ~CStartMenuDummy();
200 DECLARE_REGISTRY_RESOURCEID(IDR_STARTMENU
)
205 static STDMETHODIMP
CreateInstance(void *pv
, REFIID riid
, LPVOID
*ppv
)
211 return CLASS_E_NOAGGREGATION
;
212 return CStartMenu_Constructor(riid
, ppv
);
217 /**************************************************************************
220 class CShell32Module
: public CComModule
225 CComCreatorCentralInstance
< ATL::CComObject
< CDrivesFolder
> >::Term();
226 CComCreatorCentralInstance
< ATL::CComObject
< CDesktopFolder
> >::Term();
232 BEGIN_OBJECT_MAP(ObjectMap
)
233 OBJECT_ENTRY(CLSID_ShellFSFolder
, CFSFolder
)
234 OBJECT_ENTRY(CLSID_MyComputer
, CDrivesFolder
)
235 OBJECT_ENTRY(CLSID_ShellDesktop
, CDesktopFolder
)
236 OBJECT_ENTRY(CLSID_ShellItem
, CShellItem
)
237 OBJECT_ENTRY(CLSID_ShellLink
, CShellLink
)
238 OBJECT_ENTRY(CLSID_Shell
, CShellDispatch
)
239 OBJECT_ENTRY(CLSID_DragDropHelper
, CDropTargetHelper
)
240 OBJECT_ENTRY(CLSID_ControlPanel
, CControlPanelFolder
)
241 OBJECT_ENTRY(CLSID_MyDocuments
, CMyDocsFolder
)
242 OBJECT_ENTRY(CLSID_NetworkPlaces
, CNetFolder
)
243 OBJECT_ENTRY(CLSID_FontsFolderShortcut
, CFontsFolder
)
244 OBJECT_ENTRY(CLSID_Printers
, CPrinterFolder
)
245 OBJECT_ENTRY(CLSID_AdminFolderShortcut
, CAdminToolsFolder
)
246 OBJECT_ENTRY(CLSID_ShellFldSetExt
, CFolderOptions
)
247 OBJECT_ENTRY(CLSID_RecycleBin
, CRecycleBin
)
248 OBJECT_ENTRY(CLSID_OpenWithMenu
, COpenWithMenu
)
249 OBJECT_ENTRY(CLSID_NewMenu
, CNewMenu
)
250 OBJECT_ENTRY(CLSID_StartMenu
, CStartMenuDummy
)
251 OBJECT_ENTRY(CLSID_MenuBandSite
, CMenuSite
)
252 OBJECT_ENTRY(CLSID_MenuBand
, CMenuBand
)
253 OBJECT_ENTRY(CLSID_MenuDeskBar
, CMenuDeskBar
)
254 OBJECT_ENTRY(CLSID_MergedFolder
, CMergedFolder
)
255 OBJECT_ENTRY(CLSID_RebarBandSite
, CBandSite
)
256 OBJECT_ENTRY(CLSID_ExeDropHandler
, CExeDropHandler
)
257 OBJECT_ENTRY(CLSID_QueryAssociations
, CQueryAssociations
)
260 CShell32Module gModule
;
263 /***********************************************************************
264 * DllGetVersion [SHELL32.@]
266 * Retrieves version information of the 'SHELL32.DLL'
269 * pdvi [O] pointer to version information structure.
273 * Failure: E_INVALIDARG
276 * Returns version of a shell32.dll from IE4.01 SP1.
279 STDAPI
DllGetVersion(DLLVERSIONINFO
*pdvi
)
281 /* FIXME: shouldn't these values come from the version resource? */
282 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO
) ||
283 pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
285 pdvi
->dwMajorVersion
= WINE_FILEVERSION_MAJOR
;
286 pdvi
->dwMinorVersion
= WINE_FILEVERSION_MINOR
;
287 pdvi
->dwBuildNumber
= WINE_FILEVERSION_BUILD
;
288 pdvi
->dwPlatformID
= WINE_FILEVERSION_PLATFORMID
;
289 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
291 DLLVERSIONINFO2
*pdvi2
= (DLLVERSIONINFO2
*)pdvi
;
294 pdvi2
->ullVersion
= MAKEDLLVERULL(WINE_FILEVERSION_MAJOR
,
295 WINE_FILEVERSION_MINOR
,
296 WINE_FILEVERSION_BUILD
,
297 WINE_FILEVERSION_PLATFORMID
);
299 TRACE("%u.%u.%u.%u\n",
300 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
301 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
306 WARN("wrong DLLVERSIONINFO size from app\n");
311 /*************************************************************************
312 * global variables of the shell32.dll
313 * all are once per process
316 HINSTANCE shell32_hInstance
;
318 void *operator new (size_t, void *buf
)
323 /*************************************************************************
327 * calling oleinitialize here breaks sone apps.
329 STDAPI_(BOOL
) DllMain(HINSTANCE hInstance
, DWORD dwReason
, LPVOID fImpLoad
)
331 TRACE("%p 0x%x %p\n", hInstance
, dwReason
, fImpLoad
);
332 if (dwReason
== DLL_PROCESS_ATTACH
)
334 shell32_hInstance
= hInstance
;
335 gModule
.Init(ObjectMap
, hInstance
, &LIBID_Shell32
);
337 DisableThreadLibraryCalls (hInstance
);
339 /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
340 GetModuleFileNameW(hInstance
, swShell32Name
, MAX_PATH
);
341 swShell32Name
[MAX_PATH
- 1] = '\0';
343 /* Initialize comctl32 */
344 INITCOMMONCONTROLSEX InitCtrls
;
345 InitCtrls
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
346 InitCtrls
.dwICC
= ICC_WIN95_CLASSES
| ICC_DATE_CLASSES
| ICC_USEREX_CLASSES
;
347 InitCommonControlsEx(&InitCtrls
);
349 /* Bad idea, initialization in DllMain! */
350 InitChangeNotifications();
352 else if (dwReason
== DLL_PROCESS_DETACH
)
354 shell32_hInstance
= NULL
;
356 FreeChangeNotifications();
362 /***********************************************************************
363 * DllCanUnloadNow (SHELL32.@)
365 STDAPI
DllCanUnloadNow()
367 return gModule
.DllCanUnloadNow();
370 /*************************************************************************
371 * DllGetClassObject [SHELL32.@]
372 * SHDllGetClassObject [SHELL32.128]
374 STDAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
378 TRACE("CLSID:%s,IID:%s\n", shdebugstr_guid(&rclsid
), shdebugstr_guid(&riid
));
380 hResult
= gModule
.DllGetClassObject(rclsid
, riid
, ppv
);
381 TRACE("-- pointer to class factory: %p\n", *ppv
);
385 /***********************************************************************
386 * DllRegisterServer (SHELL32.@)
388 STDAPI
DllRegisterServer()
392 hr
= gModule
.DllRegisterServer(TRUE
);
396 hr
= gModule
.UpdateRegistryFromResource(IDR_FOLDEROPTIONS
, TRUE
, NULL
);
400 hr
= SHELL_RegisterShellFolders();
407 /***********************************************************************
408 * DllUnregisterServer (SHELL32.@)
410 STDAPI
DllUnregisterServer()
414 hr
= gModule
.DllUnregisterServer(TRUE
);
418 hr
= gModule
.UpdateRegistryFromResource(IDR_FOLDEROPTIONS
, FALSE
, NULL
);
425 /*************************************************************************
426 * DllInstall [SHELL32.@]
430 * BOOL bInstall - TRUE for install, FALSE for uninstall
431 * LPCWSTR pszCmdLine - command line (unused by shell32?)
434 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
436 FIXME("%s %s: stub\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
437 return S_OK
; /* indicate success */