ReactOS 0.4.16-dev-199-g898cc56
shellservice.cpp File Reference
#include "precomp.h"
Include dependency graph for shellservice.cpp:

Go to the source code of this file.

Functions

static int CALLBACK InitializeAllCallback (void *pItem, void *pData)
 
static int CALLBACK ShutdownAllCallback (void *pItem, void *pData)
 
static int CALLBACK DeleteAllEnumCallback (void *pItem, void *pData)
 
HRESULT InitShellServices (HDPA *phdpa)
 
HRESULT ShutdownShellServices (HDPA hdpa)
 

Function Documentation

◆ DeleteAllEnumCallback()

static int CALLBACK DeleteAllEnumCallback ( void pItem,
void pData 
)
static

Definition at line 40 of file shellservice.cpp.

41{
42 IOleCommandTarget * pOct = reinterpret_cast<IOleCommandTarget *>(pItem);
43 TRACE("Releasing SSO %p\n", pOct);
44 pOct->Release();
45 return TRUE;
46}
#define TRUE
Definition: types.h:120
ULONG Release()
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by ShutdownShellServices().

◆ InitializeAllCallback()

static int CALLBACK InitializeAllCallback ( void pItem,
void pData 
)
static

Definition at line 23 of file shellservice.cpp.

24{
25 IOleCommandTarget * pOct = reinterpret_cast<IOleCommandTarget *>(pItem);
26 HRESULT * phr = reinterpret_cast<HRESULT *>(pData);
27 TRACE("Initializing SSO %p\n", pOct);
28 *phr = pOct->Exec(&CGID_ShellServiceObject, OLECMDID_NEW, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
29 return SUCCEEDED(*phr);
30}
#define NULL
Definition: types.h:112
HRESULT Exec([in, unique] const GUID *pguidCmdGroup, [in] DWORD nCmdID, [in] DWORD nCmdexecopt, [in, unique] VARIANT *pvaIn, [in, out, unique] VARIANT *pvaOut)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830

Referenced by InitShellServices().

◆ InitShellServices()

HRESULT InitShellServices ( HDPA phdpa)

Definition at line 48 of file shellservice.cpp.

49{
50 IOleCommandTarget * pOct;
51 HKEY hkey;
55 DWORD type;
56 LONG ret;
57 HDPA hdpa;
58 HRESULT hr = S_OK;
59 int count = 0;
60
61 *phdpa = NULL;
62
63 TRACE("Enumerating Shell Service Object GUIDs...\n");
64
66 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ShellServiceObjectDelayLoad",
67 &hkey))
68 {
69 ERR("RegOpenKeyW failed.\n");
71 }
72
73 hdpa = DPA_Create(5);
74
75 /* Enumerate */
76 do
77 {
78 DWORD name_len = MAX_PATH;
79 DWORD value_len = sizeof(value); /* byte count! */
80
81 ret = RegEnumValueW(hkey, count, name, &name_len, 0, &type, (LPBYTE) &value, &value_len);
82 if (ret)
83 break;
84
85 if (type != REG_SZ)
86 {
87 WARN("Value type was not REG_SZ.\n");
88 continue;
89 }
90
93 {
94 ERR("CLSIDFromString failed %08x.\n", hr);
95 goto cleanup;
96 }
97
98 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IOleCommandTarget, &pOct));
100 {
101 ERR("CoCreateInstance failed %08x.\n", hr);
102 goto cleanup;
103 }
104
105 DPA_AppendPtr(hdpa, pOct);
106
107 count++;
108 }
109 while (1);
110
112 {
113 ERR("RegEnumValueW failed %08x.\n", ret);
115 goto cleanup;
116 }
117
118 /* Initialize */
121 goto cleanup;
122
123 RegCloseKey(hkey);
124
125 *phdpa = hdpa;
126 return count > 0 ? S_OK : S_FALSE;
127
128cleanup:
129 RegCloseKey(hkey);
130 *phdpa = NULL;
132 return hr;
133}
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2830
VOID WINAPI DPA_EnumCallback(HDPA hdpa, PFNDPAENUMCALLBACK enumProc, LPVOID lParam)
Definition: dpa.c:969
HDPA WINAPI DPA_Create(INT nGrow)
Definition: dpa.c:950
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define MAX_PATH
Definition: compat.h:34
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
static void cleanup(void)
Definition: main.c:1335
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define S_OK
Definition: intsafe.h:52
#define REG_SZ
Definition: layer.c:22
REFCLSID clsid
Definition: msctf.c:82
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define DPA_AppendPtr(hdpa, pitem)
Definition: commctrl.h:4963
static int CALLBACK InitializeAllCallback(void *pItem, void *pData)
HRESULT ShutdownShellServices(HDPA hdpa)
HRESULT hr
Definition: shlfolder.c:183
Definition: dpa.c:49
Definition: name.c:39
unsigned char * LPBYTE
Definition: typedefs.h:53
Definition: pdh_main.c:94
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define S_FALSE
Definition: winerror.h:2357
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define IID_PPV_ARG(Itype, ppType)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CTrayWindow::OnCreate().

◆ ShutdownAllCallback()

static int CALLBACK ShutdownAllCallback ( void pItem,
void pData 
)
static

Definition at line 32 of file shellservice.cpp.

33{
34 IOleCommandTarget * pOct = reinterpret_cast<IOleCommandTarget *>(pItem);
35 TRACE("Shutting down SSO %p\n", pOct);
36 pOct->Exec(&CGID_ShellServiceObject, OLECMDID_SAVE, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
37 return TRUE;
38}

Referenced by ShutdownShellServices().

◆ ShutdownShellServices()

HRESULT ShutdownShellServices ( HDPA  hdpa)

Definition at line 135 of file shellservice.cpp.

136{
139 DPA_Destroy(hdpa);
140 return S_OK;
141}
BOOL WINAPI DPA_Destroy(HDPA hdpa)
Definition: dpa.c:396
static int CALLBACK DeleteAllEnumCallback(void *pItem, void *pData)
static int CALLBACK ShutdownAllCallback(void *pItem, void *pData)

Referenced by InitShellServices(), and CTrayWindow::~CTrayWindow().