ReactOS 0.4.16-dev-197-g92996da
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)
 
VOID WINAPI ShowFolderOptionsDialog (UINT Page, BOOL Async)
 

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 13 of file misc.cpp.

◆ COBJMACROS

#define COBJMACROS

Definition at line 16 of file misc.cpp.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 14 of file misc.cpp.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 12 of file misc.cpp.

Function Documentation

◆ _RegSetStringValueW()

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

Definition at line 71 of file misc.cpp.

72{
73 DWORD dwStringDataLen = lstrlenW(lpStringData);
74
75 return RegSetValueExW(hKey, lpValueName, 0, REG_SZ, (BYTE *) lpStringData, 2 * (dwStringDataLen + 1));
76}
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:4882
#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 160 of file misc.cpp.

161{
162 gModule.DllCanUnloadNow();
163 return S_FALSE;
164}
CRShellModule gModule
Definition: misc.cpp:66
#define S_FALSE
Definition: winerror.h:2357

Referenced by COMPOBJ_DllList_Add().

◆ DllGetClassObject()

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

Definition at line 252 of file misc.cpp.

256{
257 if (!ppv)
258 return E_INVALIDARG;
259
260 *ppv = NULL;
261
262 return ShellObjectCreatorInit<CRShellClassFactory>(rclsid, riid, ppv);
263}
#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 167 of file misc.cpp.

168{
169#if 0
170 RegisterComponent(CLSID_StartMenu, L"Shell Start Menu");
171 RegisterComponent(CLSID_MenuDeskBar, L"Shell Menu Desk Bar");
172 RegisterComponent(CLSID_MenuBand, L"Shell Menu Band");
173 RegisterComponent(CLSID_MenuBandSite, L"Shell Menu Band Site");
174 RegisterComponent(CLSID_MergedFolder, L"Merged Shell Folder");
175 RegisterComponent(CLSID_RebarBandSite, L"Shell Rebar Band Site");
176#endif
179 return S_OK;
180}
const GUID CLSID_QuickLaunchBand
HRESULT RegisterComCat()
static HRESULT RegisterComponent(REFGUID clsid, LPCWSTR szDisplayName)
Definition: misc.cpp:78
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 183 of file misc.cpp.

184{
185#if 0
187 UnregisterComponent(CLSID_MenuDeskBar);
188 UnregisterComponent(CLSID_MenuBand);
190 UnregisterComponent(CLSID_MergedFolder);
191 UnregisterComponent(CLSID_RebarBandSite);
192#endif
195 return S_OK;
196}
HRESULT UnregisterComCat()
static HRESULT UnregisterComponent(REFGUID clsid)
Definition: misc.cpp:117

◆ RegisterComponent()

static HRESULT RegisterComponent ( REFGUID  clsid,
LPCWSTR  szDisplayName 
)
static

Definition at line 78 of file misc.cpp.

79{
80 WCHAR szFilename[MAX_PATH];
81 WCHAR szClsid[MAX_PATH];
82 WCHAR szRoot[MAX_PATH];
83
84 if (!StringFromGUID2(clsid, szClsid, _countof(szClsid)))
85 return E_FAIL;
86
87 if (!GetModuleFileNameW(shell32_hInstance, szFilename, _countof(szFilename)))
88 return E_FAIL;
89
90 HRESULT hr = StringCchPrintfW(szRoot, 0x104u, L"CLSID\\%s", szClsid);
91 if (FAILED(hr))
92 return hr;
93
94 DWORD dwDisposition;
95 HKEY hkRoot;
96 if (RegCreateKeyExW(HKEY_CLASSES_ROOT, szRoot, 0, NULL, 0, KEY_WRITE, 0, &hkRoot, &dwDisposition) != 0)
97 return E_FAIL;
98
99 HKEY hkServer;
100
101 _RegSetStringValueW(hkRoot, NULL, szDisplayName);
102
103 if (RegCreateKeyExW(hkRoot, L"InprocServer32", 0, NULL, 0, KEY_SET_VALUE, 0, &hkServer, &dwDisposition) != 0)
104 {
105 RegCloseKey(hkRoot);
106 return E_FAIL;
107 }
108
109 _RegSetStringValueW(hkServer, NULL, szFilename);
110 _RegSetStringValueW(hkServer, L"ThreadingModel", L"Both");
111
112 RegCloseKey(hkServer);
113 RegCloseKey(hkRoot);
114 return S_OK;
115}
HINSTANCE shell32_hInstance
Definition: misc.cpp:69
static LSTATUS _RegSetStringValueW(HKEY hKey, LPCWSTR lpValueName, LPCWSTR lpStringData)
Definition: misc.cpp:71
#define RegCloseKey(hKey)
Definition: registry.h:49
#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:1096
#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:70
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 1320 of file CMenuBand.cpp.

1321{
1322 return ShellObjectCreator<CMenuBand>(riid, ppv);
1323}

Referenced by CRShellClassFactory::CreateInstance().

◆ RSHELL_CMenuDeskBar_CreateInstance()

HRESULT WINAPI RSHELL_CMenuDeskBar_CreateInstance ( REFIID  riid,
LPVOID ppv 
)

Definition at line 855 of file CMenuDeskBar.cpp.

856{
857 return ShellObjectCreator<CMenuDeskBar>(riid, ppv);
858}

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 592 of file CStartMenu.cpp.

593{
594 CComPtr<IShellMenu> pShellMenu;
595 CComPtr<IBandSite> pBandSite;
596 CComPtr<IDeskBar> pDeskBar;
597
598 HRESULT hr;
599 IShellFolder * psf;
600
601 LPITEMIDLIST pidlProgramsAbsolute;
602 LPITEMIDLIST pidlPrograms;
603 CComPtr<IShellFolder> psfPrograms;
604
607 return hr;
608
611 return hr;
612
615 return hr;
616
617 CComObject<CShellMenuCallback> *pCallback;
618 hr = CComObject<CShellMenuCallback>::CreateInstance(&pCallback);
620 return hr;
621
622 pCallback->AddRef(); // CreateInstance returns object with 0 ref count */
623 pCallback->Initialize(pShellMenu, pBandSite, pDeskBar);
624
625 hr = pShellMenu->Initialize(pCallback, (UINT) -1, 0, SMINIT_TOPLEVEL | SMINIT_VERTICAL);
627 return hr;
628
629 hr = GetStartMenuFolder(&psf);
631 return hr;
632
633 /* psf is a merged folder, so now we want to get the pidl of the programs item from the merged folder */
634 {
635 hr = SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAMS, &pidlProgramsAbsolute);
637 {
638 WARN("USER Programs folder not found\n");
639 hr = SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_PROGRAMS, &pidlProgramsAbsolute);
641 return hr;
642 }
643
644 LPCITEMIDLIST pcidlPrograms;
645 CComPtr<IShellFolder> psfParent;
646 STRRET str;
647 TCHAR szDisplayName[MAX_PATH];
648
649 hr = SHBindToParent(pidlProgramsAbsolute, IID_PPV_ARG(IShellFolder, &psfParent), &pcidlPrograms);
651 return hr;
652
653 hr = psfParent->GetDisplayNameOf(pcidlPrograms, SHGDN_FORPARSING | SHGDN_INFOLDER, &str);
655 return hr;
656
657 StrRetToBuf(&str, pcidlPrograms, szDisplayName, _countof(szDisplayName));
658 ILFree(pidlProgramsAbsolute);
659
660 /* We got the display name from the fs folder and we parse it with the merged folder here */
661 hr = psf->ParseDisplayName(NULL, NULL, szDisplayName, NULL, &pidlPrograms, NULL);
663 return hr;
664 }
665
666 hr = GetProgramsFolder(&psfPrograms);
668 return hr;
669
670 hr = pCallback->_SetProgramsFolder(psfPrograms, pidlPrograms);
672 return hr;
673
674 hr = pShellMenu->SetShellFolder(psf, NULL, NULL, SMSET_TOP);
676 return hr;
677
678 hr = pDeskBar->SetClient(pBandSite);
680 return hr;
681
682 hr = pBandSite->AddBand(pShellMenu);
684 return hr;
685
686 return pDeskBar->QueryInterface(riid, ppv);
687}
static HRESULT GetProgramsFolder(IShellFolder **ppsfStartMenu)
Definition: CStartMenu.cpp:585
static HRESULT GetStartMenuFolder(IShellFolder **ppsfStartMenu)
Definition: CStartMenu.cpp:580
#define WARN(fmt,...)
Definition: precomp.h:61
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3257
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:946
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1356
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 CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2195
#define CSIDL_PROGRAMS
Definition: shlobj.h:2175
#define StrRetToBuf
Definition: shlwapi.h:1795
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().

◆ ShowFolderOptionsDialog()

VOID WINAPI ShowFolderOptionsDialog ( UINT  Page,
BOOL  Async 
)

Definition at line 265 of file misc.cpp.

266{
267 char buf[MAX_PATH];
268 wsprintfA(buf, "rundll32.exe shell32.dll,Options_RunDLL %u", Page);
270}
UINT WINAPI DECLSPEC_HOTPATCH WinExec(LPCSTR lpCmdLine, UINT uCmdShow)
Definition: proc.c:4779
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
Definition: mm.h:1306
int WINAPIV wsprintfA(_Out_ LPSTR, _In_ _Printf_format_string_ LPCSTR,...)
#define SW_SHOW
Definition: winuser.h:778

◆ STDAPI_()

STDAPI_ ( BOOL  )

◆ UnregisterComponent()

static HRESULT UnregisterComponent ( REFGUID  clsid)
static

Definition at line 117 of file misc.cpp.

118{
119 WCHAR szClsid[MAX_PATH];
120 WCHAR szRoot[MAX_PATH];
121 HKEY hkRoot;
122
123 if (!StringFromGUID2(clsid, szClsid, _countof(szClsid)))
124 return E_FAIL;
125
126 HRESULT hr = StringCchPrintfW(szRoot, 0x104u, L"CLSID\\%s", szClsid);
127 if (FAILED(hr))
128 return hr;
129
130 if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szRoot, 0, KEY_WRITE, &hkRoot) != 0)
131 return E_FAIL;
132
133 RegDeleteKeyW(hkRoot, L"InprocServer32");
134 RegCloseKey(hkRoot);
135
137
138 return S_OK;
139}
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239

Referenced by DllUnregisterServer().

◆ WinList_Init()

DWORD WINAPI WinList_Init ( void  )

Definition at line 55 of file misc.cpp.

56{
57 /* do something here (perhaps we may want to add our own implementation fo win8) */
58 return 0;
59}

Variable Documentation

◆ dwReason

◆ fImpLoad

DWORD LPVOID fImpLoad
Initial value:
{
{
}
{
gModule.Term();
}
return TRUE
DWORD dwReason
Definition: misc.cpp:141
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 141 of file misc.cpp.

Referenced by DllMain().

◆ gModule

CRShellModule gModule

Definition at line 66 of file misc.cpp.

Referenced by DllCanUnloadNow().

◆ gWinModule

CAtlWinModule gWinModule

Definition at line 67 of file misc.cpp.

◆ shell32_hInstance

HINSTANCE shell32_hInstance = NULL

Definition at line 69 of file misc.cpp.

Referenced by RegisterComponent().