ReactOS  0.4.14-dev-854-gb9426a3
SSOThread Struct Reference

#include <shellservices.h>

Inheritance diagram for SSOThread:
Collaboration diagram for SSOThread:

Public Member Functions

int Run ()
 

Detailed Description

Definition at line 33 of file shellservices.h.

Member Function Documentation

◆ Run()

int SSOThread::Run ( void  )

Definition at line 34 of file shellservices.cpp.

35 {
37 
38  HKEY hkey;
39  CLSID clsid;
41 
42  typedef vector<SIfacePtr<IOleCommandTarget>*> SSOVector;
43  SSOVector sso_ptrs;
44 
45  if (!RegOpenKey(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ShellServiceObjectDelayLoad"), &hkey)) {
46  for(int idx=0; ; ++idx) {
47  DWORD name_len = MAX_PATH;
48  DWORD value_len = sizeof(value);
49 
50  if (RegEnumValueW(hkey, idx, name, &name_len, 0, NULL, (LPBYTE)&value, &value_len))
51  break;
52 
53  if (!_alive)
54  break;
55 
57 
58  if (CLSIDFromString(value, &clsid) == NOERROR) {
59  if (SUCCEEDED(sso_ptr->CreateInstance(clsid, IID_IOleCommandTarget))) {
60  if (SUCCEEDED((*sso_ptr)->Exec(&CGID_ShellServiceObject, OLECMDID_NEW, OLECMDEXECOPT_DODEFAULT, NULL, NULL)))
61  sso_ptrs.push_back(sso_ptr);
62  }
63  }
64  }
65 
66  RegCloseKey(hkey);
67  }
68 
69  if (!sso_ptrs.empty()) {
70  MSG msg;
71 
72  while(_alive) {
74  break; // _evtFinish has been set.
75 
76  while(_alive) {
77  if (!PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
78  break;
79 
80  if (msg.message == WM_QUIT)
81  break;
82 
85  }
86  }
87 
88  // shutdown all running Shell Service Objects
89  for(SSOVector::iterator it=sso_ptrs.begin(); it!=sso_ptrs.end(); ++it) {
90  SIfacePtr<IOleCommandTarget>* sso_ptr = *it;
91  (*sso_ptr)->Exec(&CGID_ShellServiceObject, OLECMDID_SAVE, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
92  delete sso_ptr;
93  }
94  }
95 
96  return 0;
97 }
#define DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define PeekMessage
Definition: winuser.h:5805
#define NOERROR
Definition: winerror.h:2354
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define WM_QUIT
Definition: winuser.h:1605
HRESULT Exec([in, unique] const GUID *pguidCmdGroup, [in] DWORD nCmdID, [in] DWORD nCmdexecopt, [in, unique] VARIANT *pvaIn, [in, out, unique] VARIANT *pvaOut)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int idx
Definition: utils.c:41
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 WAIT_OBJECT_0
Definition: winbase.h:387
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
REFCLSID clsid
Definition: msctf.c:82
GLsizei const GLfloat * value
Definition: glext.h:6069
#define TEXT(s)
Definition: k32.h:26
#define QS_ALLINPUT
Definition: winuser.h:874
wrapper class for COM interface pointers
Definition: shellclasses.h:332
#define msg(x)
Definition: auth_time.c:54
Definition: name.c:38
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
#define PM_REMOVE
Definition: winuser.h:1182
#define INFINITE
Definition: serial.h:102
#define RegOpenKey
Definition: winreg.h:519
#define SUCCEEDED(hr)
Definition: intsafe.h:57
COM Initialisation.
Definition: shellclasses.h:178
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

The documentation for this struct was generated from the following files: