ReactOS 0.4.15-dev-5664-g3bf4ef6
misc.cpp File Reference
#include <stdio.h>
#include <tchar.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <wingdi.h>
#include <winnls.h>
#include <wincon.h>
#include <shellapi.h>
#include <shlobj.h>
#include <shlobj_undoc.h>
#include <shlwapi.h>
#include <shlguid_undoc.h>
#include <uxtheme.h>
#include <strsafe.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <undocshell.h>
#include <undocuser.h>
#include <shellutils.h>
#include <CQuickLaunchBand.h>
#include <wine/debug.h>
Include dependency graph for misc.cpp:

Go to the source code of this file.

Classes

class  CRShellModule
 
class  CRShellClassFactory
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define COBJMACROS
 

Functions

HRESULT WINAPI RSHELL_CStartMenu_CreateInstance (REFIID riid, void **ppv)
 
HRESULT WINAPI RSHELL_CMenuDeskBar_CreateInstance (REFIID riid, LPVOID *ppv)
 
HRESULT WINAPI RSHELL_CMenuSite_CreateInstance (REFIID riid, LPVOID *ppv)
 
HRESULT WINAPI RSHELL_CMenuBand_CreateInstance (REFIID riid, LPVOID *ppv)
 
HRESULT WINAPI RSHELL_CMergedFolder_CreateInstance (REFIID riid, LPVOID *ppv)
 
DWORD WINAPI WinList_Init (void)
 
static LSTATUS _RegSetStringValueW (HKEY hKey, LPCWSTR lpValueName, LPCWSTR lpStringData)
 
static HRESULT RegisterComponent (REFGUID clsid, LPCWSTR szDisplayName)
 
static HRESULT UnregisterComponent (REFGUID clsid)
 
 STDAPI_ (BOOL) DllMain(HINSTANCE hInstance
 
HRESULT WINAPI DllCanUnloadNow (void)
 
STDAPI DllRegisterServer (void)
 
STDAPI DllUnregisterServer (void)
 
STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv)
 

Variables

HINSTANCE shell32_hInstance = NULL
 
CRShellModule gModule
 
CAtlWinModule gWinModule
 
DWORD dwReason
 
DWORD LPVOID fImpLoad
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 26 of file misc.cpp.

◆ COBJMACROS

#define COBJMACROS

Definition at line 29 of file misc.cpp.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 27 of file misc.cpp.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 25 of file misc.cpp.

Function Documentation

◆ _RegSetStringValueW()

static LSTATUS _RegSetStringValueW ( HKEY  hKey,
LPCWSTR  lpValueName,
LPCWSTR  lpStringData 
)
inlinestatic

Definition at line 84 of file misc.cpp.

85{
86 DWORD dwStringDataLen = lstrlenW(lpStringData);
87
88 return RegSetValueExW(hKey, lpValueName, 0, REG_SZ, (BYTE *) lpStringData, 2 * (dwStringDataLen + 1));
89}
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4900
#define lstrlenW
Definition: compat.h:750
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
unsigned char BYTE
Definition: xxhash.c:193

Referenced by RegisterComponent().

◆ DllCanUnloadNow()

HRESULT WINAPI DllCanUnloadNow ( void  )

Definition at line 173 of file misc.cpp.

174{
175 gModule.DllCanUnloadNow();
176 return S_FALSE;
177}
CRShellModule gModule
Definition: misc.cpp:79
#define S_FALSE
Definition: winerror.h:2357

Referenced by COMPOBJ_DllList_Add().

◆ DllGetClassObject()

STDAPI DllGetClassObject ( REFCLSID  rclsid,
REFIID  riid,
LPVOID ppv 
)

Definition at line 265 of file misc.cpp.

269{
270 if (!ppv)
271 return E_INVALIDARG;
272
273 *ppv = NULL;
274
275 return ShellObjectCreatorInit<CRShellClassFactory>(rclsid, riid, ppv);
276}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39

◆ DllRegisterServer()

STDAPI DllRegisterServer ( void  )

Definition at line 180 of file misc.cpp.

181{
182#if 0
183 RegisterComponent(CLSID_StartMenu, L"Shell Start Menu");
184 RegisterComponent(CLSID_MenuDeskBar, L"Shell Menu Desk Bar");
185 RegisterComponent(CLSID_MenuBand, L"Shell Menu Band");
186 RegisterComponent(CLSID_MenuBandSite, L"Shell Menu Band Site");
187 RegisterComponent(CLSID_MergedFolder, L"Merged Shell Folder");
188 RegisterComponent(CLSID_RebarBandSite, L"Shell Rebar Band Site");
189#endif
192 return S_OK;
193}
const GUID CLSID_QuickLaunchBand
HRESULT RegisterComCat()
static HRESULT RegisterComponent(REFGUID clsid, LPCWSTR szDisplayName)
Definition: misc.cpp:91
const GUID CLSID_MenuBandSite
const GUID CLSID_StartMenu
#define S_OK
Definition: intsafe.h:52
#define L(x)
Definition: ntvdm.h:50

◆ DllUnregisterServer()

STDAPI DllUnregisterServer ( void  )

Definition at line 196 of file misc.cpp.

197{
198#if 0
200 UnregisterComponent(CLSID_MenuDeskBar);
201 UnregisterComponent(CLSID_MenuBand);
203 UnregisterComponent(CLSID_MergedFolder);
204 UnregisterComponent(CLSID_RebarBandSite);
205#endif
208 return S_OK;
209}
HRESULT UnregisterComCat()
static HRESULT UnregisterComponent(REFGUID clsid)
Definition: misc.cpp:130

◆ RegisterComponent()

static HRESULT RegisterComponent ( REFGUID  clsid,
LPCWSTR  szDisplayName 
)
static

Definition at line 91 of file misc.cpp.

92{
93 WCHAR szFilename[MAX_PATH];
94 WCHAR szClsid[MAX_PATH];
95 WCHAR szRoot[MAX_PATH];
96
97 if (!StringFromGUID2(clsid, szClsid, _countof(szClsid)))
98 return E_FAIL;
99
100 if (!GetModuleFileNameW(shell32_hInstance, szFilename, _countof(szFilename)))
101 return E_FAIL;
102
103 HRESULT hr = StringCchPrintfW(szRoot, 0x104u, L"CLSID\\%s", szClsid);
104 if (FAILED(hr))
105 return hr;
106
107 DWORD dwDisposition;
108 HKEY hkRoot;
109 if (RegCreateKeyExW(HKEY_CLASSES_ROOT, szRoot, 0, NULL, 0, KEY_WRITE, 0, &hkRoot, &dwDisposition) != 0)
110 return E_FAIL;
111
112 HKEY hkServer;
113
114 _RegSetStringValueW(hkRoot, NULL, szDisplayName);
115
116 if (RegCreateKeyExW(hkRoot, L"InprocServer32", 0, NULL, 0, KEY_SET_VALUE, 0, &hkServer, &dwDisposition) != 0)
117 {
118 RegCloseKey(hkRoot);
119 return E_FAIL;
120 }
121
122 _RegSetStringValueW(hkServer, NULL, szFilename);
123 _RegSetStringValueW(hkServer, L"ThreadingModel", L"Both");
124
125 RegCloseKey(hkServer);
126 RegCloseKey(hkRoot);
127 return S_OK;
128}
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
static LSTATUS _RegSetStringValueW(HKEY hKey, LPCWSTR lpValueName, LPCWSTR lpStringData)
Definition: misc.cpp:84
#define RegCloseKey(hKey)
Definition: registry.h:47
#define E_FAIL
Definition: ddrawi.h:102
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
#define FAILED(hr)
Definition: intsafe.h:51
REFCLSID clsid
Definition: msctf.c:82
#define KEY_WRITE
Definition: nt_native.h:1031
#define KEY_SET_VALUE
Definition: nt_native.h:1017
HRESULT hr
Definition: shlfolder.c:183
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DllRegisterServer().

◆ RSHELL_CMenuBand_CreateInstance()

HRESULT WINAPI RSHELL_CMenuBand_CreateInstance ( REFIID  riid,
LPVOID ppv 
)

Definition at line 1313 of file CMenuBand.cpp.

1314{
1315 return ShellObjectCreator<CMenuBand>(riid, ppv);
1316}

Referenced by CRShellClassFactory::CreateInstance().

◆ RSHELL_CMenuDeskBar_CreateInstance()

HRESULT WINAPI RSHELL_CMenuDeskBar_CreateInstance ( REFIID  riid,
LPVOID ppv 
)

Definition at line 852 of file CMenuDeskBar.cpp.

853{
854 return ShellObjectCreator<CMenuDeskBar>(riid, ppv);
855}

Referenced by CRShellClassFactory::CreateInstance().

◆ RSHELL_CMenuSite_CreateInstance()

HRESULT WINAPI RSHELL_CMenuSite_CreateInstance ( REFIID  riid,
LPVOID ppv 
)

Definition at line 360 of file CMenuSite.cpp.

361{
362 return ShellObjectCreator<CMenuSite>(riid, ppv);
363}

Referenced by CRShellClassFactory::CreateInstance().

◆ RSHELL_CMergedFolder_CreateInstance()

HRESULT WINAPI RSHELL_CMergedFolder_CreateInstance ( REFIID  riid,
LPVOID ppv 
)

Definition at line 813 of file CMergedFolder.cpp.

814{
815 return ShellObjectCreator<CMergedFolder>(riid, ppv);
816}

Referenced by CRShellClassFactory::CreateInstance().

◆ RSHELL_CStartMenu_CreateInstance()

HRESULT WINAPI RSHELL_CStartMenu_CreateInstance ( REFIID  riid,
void **  ppv 
)

Definition at line 490 of file CStartMenu.cpp.

491{
492 CComPtr<IShellMenu> pShellMenu;
493 CComPtr<IBandSite> pBandSite;
494 CComPtr<IDeskBar> pDeskBar;
495
496 HRESULT hr;
497 IShellFolder * psf;
498
499 LPITEMIDLIST pidlProgramsAbsolute;
500 LPITEMIDLIST pidlPrograms;
501 CComPtr<IShellFolder> psfPrograms;
502
505 return hr;
506
509 return hr;
510
513 return hr;
514
515 CComObject<CShellMenuCallback> *pCallback;
516 hr = CComObject<CShellMenuCallback>::CreateInstance(&pCallback);
518 return hr;
519
520 pCallback->AddRef(); // CreateInstance returns object with 0 ref count */
521 pCallback->Initialize(pShellMenu, pBandSite, pDeskBar);
522
523 hr = pShellMenu->Initialize(pCallback, (UINT) -1, 0, SMINIT_TOPLEVEL | SMINIT_VERTICAL);
525 return hr;
526
527 hr = GetStartMenuFolder(&psf);
529 return hr;
530
531 /* psf is a merged folder, so now we want to get the pidl of the programs item from the merged folder */
532 {
533 hr = SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAMS, &pidlProgramsAbsolute);
535 {
536 WARN("USER Programs folder not found.\n");
537 hr = SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_PROGRAMS, &pidlProgramsAbsolute);
539 return hr;
540 }
541
542 LPCITEMIDLIST pcidlPrograms;
543 CComPtr<IShellFolder> psfParent;
544 STRRET str;
545 TCHAR szDisplayName[MAX_PATH];
546
547 hr = SHBindToParent(pidlProgramsAbsolute, IID_PPV_ARG(IShellFolder, &psfParent), &pcidlPrograms);
549 return hr;
550
551 hr = psfParent->GetDisplayNameOf(pcidlPrograms, SHGDN_FORPARSING | SHGDN_INFOLDER, &str);
553 return hr;
554
555 StrRetToBuf(&str, pcidlPrograms, szDisplayName, _countof(szDisplayName));
556 ILFree(pidlProgramsAbsolute);
557
558 /* We got the display name from the fs folder and we parse it with the merged folder here */
559 hr = psf->ParseDisplayName(NULL, NULL, szDisplayName, NULL, &pidlPrograms, NULL);
561 return hr;
562 }
563
564 hr = GetProgramsFolder(&psfPrograms);
566 return hr;
567
568 hr = pCallback->_SetProgramsFolder(psfPrograms, pidlPrograms);
570 return hr;
571
572 hr = pShellMenu->SetShellFolder(psf, NULL, NULL, SMSET_TOP);
574 return hr;
575
576 hr = pDeskBar->SetClient(pBandSite);
578 return hr;
579
580 hr = pBandSite->AddBand(pShellMenu);
582 return hr;
583
584 return pDeskBar->QueryInterface(riid, ppv);
585}
static HRESULT GetProgramsFolder(IShellFolder **ppsfStartMenu)
Definition: CStartMenu.cpp:483
static HRESULT GetStartMenuFolder(IShellFolder **ppsfStartMenu)
Definition: CStartMenu.cpp:478
#define WARN(fmt,...)
Definition: debug.h:112
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3194
FxPnpStateCallbackInfo * pCallback
HRESULT ParseDisplayName([in] HWND hwndOwner, [in] LPBC pbcReserved, [in, string] LPOLESTR lpszDisplayName, [out] ULONG *pchEaten, [out] PIDLIST_RELATIVE *ppidl, [in, out, unique] ULONG *pdwAttributes)
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
unsigned int UINT
Definition: ndis.h:50
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1337
const WCHAR * str
#define CMenuSite_CreateInstance
Definition: shellmenu.h:87
#define CMenuDeskBar_CreateInstance
Definition: shellmenu.h:75
#define CMenuBand_CreateInstance
Definition: shellmenu.h:81
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2047
#define CSIDL_PROGRAMS
Definition: shlobj.h:2027
#define StrRetToBuf
Definition: shlwapi.h:1769
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define IID_PPV_ARG(Itype, ppType)
char TCHAR
Definition: xmlstorage.h:189

Referenced by CRShellClassFactory::CreateInstance(), and CStartMenuDummy::_CreatorClass::CreateInstance().

◆ STDAPI_()

STDAPI_ ( BOOL  )

◆ UnregisterComponent()

static HRESULT UnregisterComponent ( REFGUID  clsid)
static

Definition at line 130 of file misc.cpp.

131{
132 WCHAR szClsid[MAX_PATH];
133 WCHAR szRoot[MAX_PATH];
134 HKEY hkRoot;
135
136 if (!StringFromGUID2(clsid, szClsid, _countof(szClsid)))
137 return E_FAIL;
138
139 HRESULT hr = StringCchPrintfW(szRoot, 0x104u, L"CLSID\\%s", szClsid);
140 if (FAILED(hr))
141 return hr;
142
143 if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szRoot, 0, KEY_WRITE, &hkRoot) != 0)
144 return E_FAIL;
145
146 RegDeleteKeyW(hkRoot, L"InprocServer32");
147 RegCloseKey(hkRoot);
148
150
151 return S_OK;
152}
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237

Referenced by DllUnregisterServer().

◆ WinList_Init()

DWORD WINAPI WinList_Init ( void  )

Definition at line 68 of file misc.cpp.

69{
70 /* do something here (perhaps we may want to add our own implementation fo win8) */
71 return 0;
72}

Variable Documentation

◆ dwReason

◆ fImpLoad

DWORD LPVOID fImpLoad
Initial value:
{
{
}
{
gModule.Term();
}
return TRUE
DWORD dwReason
Definition: misc.cpp:154
HINSTANCE hInstance
Definition: charmap.c:19
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85

Definition at line 154 of file misc.cpp.

Referenced by DllMain().

◆ gModule

CRShellModule gModule

Definition at line 79 of file misc.cpp.

Referenced by DllCanUnloadNow().

◆ gWinModule

CAtlWinModule gWinModule

Definition at line 80 of file misc.cpp.

◆ shell32_hInstance

HINSTANCE shell32_hInstance = NULL

Definition at line 82 of file misc.cpp.

Referenced by RegisterComponent().