ReactOS 0.4.17-dev-381-g2ec7c03
CShellDispatch.cpp File Reference
#include "precomp.h"
#include "winsvc.h"
Include dependency graph for CShellDispatch.cpp:

Go to the source code of this file.

Macros

#define IDM_SECURITY   5001
 
#define SSF_SERVERADMINUI   4
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
EXTERN_C DWORD WINAPI SHGetRestriction (LPCWSTR lpSubKey, LPCWSTR lpSubName, LPCWSTR lpValue)
 
static HRESULT PostTrayCommand (UINT cmd)
 
HRESULT VariantToIdlist (VARIANT *var, LPITEMIDLIST *idlist)
 
static BOOL is_optional_argument (const VARIANT *arg)
 
static HRESULT SHELL_OpenFolder (LPCITEMIDLIST pidl, LPCWSTR verb=NULL)
 
static HRESULT OpenFolder (VARIANT vDir, LPCWSTR verb=NULL)
 
static HRESULT OpenServiceHelper (LPCWSTR name, DWORD access, SC_HANDLE &hSvc)
 
static HRESULT SHELL32_ControlService (BSTR name, DWORD control, VARIANT &persistent)
 
HRESULT WINAPI CShellDispatch_Constructor (REFIID riid, LPVOID *ppvOut)
 

Macro Definition Documentation

◆ IDM_SECURITY

#define IDM_SECURITY   5001

Definition at line 515 of file CShellDispatch.cpp.

◆ SSF_SERVERADMINUI

#define SSF_SERVERADMINUI   4

Definition at line 535 of file CShellDispatch.cpp.

Function Documentation

◆ CShellDispatch_Constructor()

HRESULT WINAPI CShellDispatch_Constructor ( REFIID  riid,
LPVOID ppvOut 
)

Definition at line 593 of file CShellDispatch.cpp.

594{
595 return ShellObjectCreatorInit<CShellDispatch>(riid, ppvOut);
596}
REFIID riid
Definition: atlbase.h:39

Referenced by CDefViewDual::get_Application(), and CFolder::Initialize().

◆ is_optional_argument()

static BOOL is_optional_argument ( const VARIANT arg)
static

Definition at line 101 of file CShellDispatch.cpp.

102{
104}
@ VT_ERROR
Definition: compat.h:2305
#define V_ERROR(A)
Definition: oleauto.h:241
#define V_VT(A)
Definition: oleauto.h:211
#define DISP_E_PARAMNOTFOUND
Definition: winerror.h:3616

Referenced by CShellDispatch::BrowseForFolder().

◆ OpenFolder()

static HRESULT OpenFolder ( VARIANT  vDir,
LPCWSTR  verb = NULL 
)
static

Definition at line 151 of file CShellDispatch.cpp.

152{
154 HRESULT hr = VariantToIdlist(&vDir, &idlist);
155 if (hr == S_OK && SHELL_OpenFolder(idlist, verb) == S_OK)
156 {
157 return S_OK;
158 }
159 return S_FALSE;
160}
HRESULT VariantToIdlist(VARIANT *var, LPITEMIDLIST *idlist)
static HRESULT SHELL_OpenFolder(LPCITEMIDLIST pidl, LPCWSTR verb=NULL)
HRESULT hr
Definition: delayimp.cpp:582
#define S_OK
Definition: intsafe.h:52
#define S_FALSE
Definition: winerror.h:3451

Referenced by CShellDispatch::Explore(), and CShellDispatch::Open().

◆ OpenServiceHelper()

static HRESULT OpenServiceHelper ( LPCWSTR  name,
DWORD  access,
SC_HANDLE &  hSvc 
)
static

Definition at line 357 of file CShellDispatch.cpp.

358{
359 hSvc = NULL;
360 SC_HANDLE hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT);
361 if (!hScm)
363 HRESULT hr = S_OK;
364 hSvc = OpenServiceW(hScm, name, access);
365 if (!hSvc)
367 CloseServiceHandle(hScm);
368 return hr;
369}
#define NULL
Definition: types.h:112
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
#define HResultFromWin32
Definition: loader.cpp:14
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2107
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2199
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
Definition: name.c:39
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by CShellDispatch::CanStartStopService(), and SHELL32_ControlService().

◆ PostTrayCommand()

◆ SHELL32_ControlService()

static HRESULT SHELL32_ControlService ( BSTR  name,
DWORD  control,
VARIANT persistent 
)
static

Definition at line 371 of file CShellDispatch.cpp.

372{
373 BOOL persist = V_VT(&persistent) == VT_BOOL && V_BOOL(&persistent);
374 DWORD access = persist ? SERVICE_CHANGE_CONFIG : 0;
375 switch (control)
376 {
377 case 0:
379 break;
382 break;
383 }
384 SC_HANDLE hSvc;
386 if (SUCCEEDED(hr))
387 {
389 DWORD error, already;
390 if (control)
391 {
393 success = ControlService(hSvc, control, &ss);
395 already = ERROR_SERVICE_NOT_ACTIVE;
396 }
397 else
398 {
399 success = StartService(hSvc, 0, NULL);
402 }
403 hr = success ? S_OK : error == already ? S_FALSE : HRESULT_FROM_WIN32(error);
404 if (SUCCEEDED(hr) && persist)
405 {
409 }
410 CloseServiceHandle(hSvc);
411 }
412 return hr;
413}
static HRESULT OpenServiceHelper(LPCWSTR name, DWORD access, SC_HANDLE &hSvc)
@ VT_BOOL
Definition: compat.h:2306
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ss
Definition: i386-dis.c:441
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define error(str)
Definition: mkdosfs.c:1605
#define V_BOOL(A)
Definition: oleauto.h:224
#define SERVICE_START
Definition: winsvc.h:63
#define SERVICE_NO_CHANGE
Definition: winsvc.h:20
#define SERVICE_CHANGE_CONFIG
Definition: winsvc.h:60
#define StartService
Definition: winsvc.h:591
#define SERVICE_STOP
Definition: winsvc.h:64
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:42
BOOL WINAPI ControlService(SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: scm.c:622
BOOL WINAPI ChangeServiceConfigW(SC_HANDLE hService, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCWSTR lpBinaryPathName, LPCWSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCWSTR lpDependencies, LPCWSTR lpServiceStartName, LPCWSTR lpPassword, LPCWSTR lpDisplayName)
Definition: scm.c:482
Definition: dialog.c:52
#define success(from, fromstr, to, tostr)
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define ERROR_SERVICE_ALREADY_RUNNING
Definition: winerror.h:931
#define ERROR_SERVICE_NOT_ACTIVE
Definition: winerror.h:937
#define SERVICE_DEMAND_START
Definition: cmtypes.h:978
#define SERVICE_AUTO_START
Definition: cmtypes.h:977

Referenced by CShellDispatch::ServiceStart(), and CShellDispatch::ServiceStop().

◆ SHELL_OpenFolder()

static HRESULT SHELL_OpenFolder ( LPCITEMIDLIST  pidl,
LPCWSTR  verb = NULL 
)
static

Definition at line 135 of file CShellDispatch.cpp.

136{
138 sei.cbSize = sizeof(sei);
140 sei.hwnd = NULL;
141 sei.lpVerb = verb;
142 sei.lpFile = sei.lpParameters = sei.lpDirectory = NULL;
143 sei.nShow = SW_SHOW;
144 sei.lpIDList = const_cast<LPITEMIDLIST>(pidl);
145 if (ShellExecuteExW(&sei))
146 return S_OK;
149}
#define SEE_MASK_IDLIST
Definition: shellapi.h:27
#define SEE_MASK_FLAG_DDEWAIT
Definition: shellapi.h:36
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2723
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
LPCWSTR lpDirectory
Definition: shellapi.h:340
LPCWSTR lpParameters
Definition: shellapi.h:339
#define SW_SHOW
Definition: winuser.h:786

Referenced by OpenFolder().

◆ SHGetRestriction()

EXTERN_C DWORD WINAPI SHGetRestriction ( LPCWSTR  lpSubKey,
LPCWSTR  lpSubName,
LPCWSTR  lpValue 
)

Definition at line 2357 of file ordinal.c.

2358{
2359#ifdef __REACTOS__
2361 DWORD dwSize, dwValue = 0;
2362
2363 TRACE("(%s, %s, %s)\n", debugstr_w(lpSubKey), debugstr_w(lpSubName), debugstr_w(lpValue));
2364
2365 if (!lpSubKey)
2366 lpSubKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies";
2367
2368 PathCombineW(szPath, lpSubKey, lpSubName);
2369
2370 dwSize = sizeof(dwValue);
2371 if (SHGetValueW(HKEY_LOCAL_MACHINE, szPath, lpValue, NULL, &dwValue, &dwSize) == ERROR_SUCCESS)
2372 return dwValue;
2373
2374 dwSize = sizeof(dwValue);
2375 SHGetValueW(HKEY_CURRENT_USER, szPath, lpValue, NULL, &dwValue, &dwSize);
2376 return dwValue;
2377#else
2378 DWORD retval, datsize = sizeof(retval);
2379 HKEY hKey;
2380
2381 if (!lpSubKey)
2382 lpSubKey = strRegistryPolicyW;
2383
2385 if (retval != ERROR_SUCCESS)
2387 if (retval != ERROR_SUCCESS)
2388 return 0;
2389
2390 SHGetValueW(hKey, lpSubName, lpValue, NULL, &retval, &datsize);
2392 return retval;
2393#endif
2394}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI SHGetValueW(HKEY hkey, const WCHAR *subkey, const WCHAR *value, DWORD *type, void *data, DWORD *data_len)
Definition: main.c:2222
static const WCHAR strRegistryPolicyW[]
Definition: ordinal.c:2338
FxAutoRegKey hKey
#define debugstr_w
Definition: kernel32.h:32
LPCWSTR szPath
Definition: env.c:37
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define PathCombineW
Definition: pathcch.h:318
short WCHAR
Definition: pedump.c:58
#define TRACE(s)
Definition: solgame.cpp:4
int retval
Definition: wcstombs.cpp:91
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by CShellDispatch::IsRestricted(), and SHRestrictionLookup().

◆ VariantToIdlist()

HRESULT VariantToIdlist ( VARIANT var,
LPITEMIDLIST idlist 
)

Definition at line 64 of file CShellDispatch.cpp.

65{
67 if(V_VT(var) == VT_I4)
68 {
70 }
71 else if(V_VT(var) == VT_BSTR)
72 {
74 }
75 return hr;
76}
#define E_FAIL
Definition: ddrawi.h:102
@ VT_BSTR
Definition: compat.h:2303
@ VT_I4
Definition: compat.h:2298
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3384
const char * var
Definition: shader.c:5666
#define V_BSTR(A)
Definition: oleauto.h:226
#define V_I4(A)
Definition: oleauto.h:247
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:404

Referenced by CShellDispatch::AddToRecent(), CShellDispatch::BrowseForFolder(), CShellDispatch::NameSpace(), and OpenFolder().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )