ReactOS  0.4.13-dev-544-gede3fdd
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 }
HRESULT Exec([in, unique] const GUID *pguidCmdGroup, [in] DWORD nCmdID, [in] DWORD nCmdexecopt, [in, unique] VARIANT *pvaIn, [in, out, unique] VARIANT *pvaOut)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by InitShellServices().

◆ InitShellServices()

HRESULT InitShellServices ( HDPA phdpa)

Definition at line 48 of file shellservice.cpp.

49 {
50  IOleCommandTarget * pOct;
51  HKEY hkey;
52  CLSID clsid;
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  {
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 
111  if (ret != ERROR_NO_MORE_ITEMS)
112  {
113  ERR("RegEnumValueW failed %08x.\n", ret);
115  goto cleanup;
116  }
117 
118  RegCloseKey(hkey);
119 
120  /* Initialize */
122  if (FAILED_UNEXPECTEDLY(hr))
123  goto cleanup;
124 
125  *phdpa = hdpa;
126  return count > 0 ? S_OK : S_FALSE;
127 
128 cleanup:
129  *phdpa = NULL;
130  ShutdownShellServices(hdpa);
131  return hr;
132 }
HDPA WINAPI DPA_Create(INT nGrow)
Definition: dpa.c:950
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WARN(fmt,...)
Definition: debug.h:111
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define IID_PPV_ARG(Itype, ppType)
#define DPA_AppendPtr(hdpa, pitem)
Definition: commctrl.h:4929
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
#define S_FALSE
Definition: winerror.h:2357
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:2853
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:35
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
REFCLSID clsid
Definition: msctf.c:84
static const WCHAR L[]
Definition: oid.c:1250
VOID WINAPI DPA_EnumCallback(HDPA hdpa, PFNDPAENUMCALLBACK enumProc, LPVOID lParam)
Definition: dpa.c:969
GLsizei const GLfloat * value
Definition: glext.h:6069
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
Definition: name.c:36
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2247
HRESULT ShutdownShellServices(HDPA hdpa)
char * cleanup(char *str)
Definition: wpickclick.c:99
static int CALLBACK InitializeAllCallback(void *pItem, void *pData)
Definition: dpa.c:48
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

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 }
#define TRUE
Definition: types.h:120
HRESULT Exec([in, unique] const GUID *pguidCmdGroup, [in] DWORD nCmdID, [in] DWORD nCmdexecopt, [in, unique] VARIANT *pvaIn, [in, out, unique] VARIANT *pvaOut)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by ShutdownShellServices().

◆ ShutdownShellServices()

HRESULT ShutdownShellServices ( HDPA  hdpa)

Definition at line 134 of file shellservice.cpp.

135 {
138  DPA_Destroy(hdpa);
139  return S_OK;
140 }
BOOL WINAPI DPA_Destroy(HDPA hdpa)
Definition: dpa.c:396
static int CALLBACK DeleteAllEnumCallback(void *pItem, void *pData)
smooth NULL
Definition: ftsmooth.c:416
static int CALLBACK ShutdownAllCallback(void *pItem, void *pData)
VOID WINAPI DPA_EnumCallback(HDPA hdpa, PFNDPAENUMCALLBACK enumProc, LPVOID lParam)
Definition: dpa.c:969
#define S_OK
Definition: intsafe.h:59

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