ReactOS 0.4.15-dev-8076-g06e89b2
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 507 of file CShellDispatch.cpp.

◆ SSF_SERVERADMINUI

#define SSF_SERVERADMINUI   4

Definition at line 527 of file CShellDispatch.cpp.

Function Documentation

◆ CShellDispatch_Constructor()

HRESULT WINAPI CShellDispatch_Constructor ( REFIID  riid,
LPVOID ppvOut 
)

Definition at line 585 of file CShellDispatch.cpp.

586{
587 return ShellObjectCreatorInit<CShellDispatch>(riid, ppvOut);
588}
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:2513

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)
#define S_OK
Definition: intsafe.h:52
HRESULT hr
Definition: shlfolder.c:183
#define S_FALSE
Definition: winerror.h:2357

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

◆ OpenServiceHelper()

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

Definition at line 349 of file CShellDispatch.cpp.

350{
351 hSvc = NULL;
352 SC_HANDLE hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT);
353 if (!hScm)
355 HRESULT hr = S_OK;
356 hSvc = OpenServiceW(hScm, name, access);
357 if (!hSvc)
359 CloseServiceHandle(hScm);
360 return hr;
361}
#define NULL
Definition: types.h:112
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2068
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2160
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
HRESULT HResultFromWin32(DWORD hr)
Definition: shellutils.h:70
Definition: name.c:39
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14

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

◆ PostTrayCommand()

static HRESULT PostTrayCommand ( UINT  cmd)
static

Definition at line 18 of file CShellDispatch.cpp.

19{
20 HWND hTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL);
21 return hTrayWnd && PostMessageW(hTrayWnd, WM_COMMAND, cmd, 0) ? S_OK : S_FALSE;
22}
#define L(x)
Definition: ntvdm.h:50
Definition: ftp_var.h:139
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_COMMAND
Definition: winuser.h:1740
HWND WINAPI FindWindowW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR)

Referenced by CShellDispatch::CascadeWindows(), CShellDispatch::FileRun(), CShellDispatch::FindComputer(), CShellDispatch::FindFiles(), CShellDispatch::Help(), CShellDispatch::MinimizeAll(), CShellDispatch::SetTime(), CShellDispatch::TileHorizontally(), CShellDispatch::TileVertically(), CShellDispatch::ToggleDesktop(), CShellDispatch::TrayProperties(), CShellDispatch::UndoMinimizeALL(), and CShellDispatch::WindowsSecurity().

◆ SHELL32_ControlService()

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

Definition at line 363 of file CShellDispatch.cpp.

364{
365 BOOL persist = V_VT(&persistent) == VT_BOOL && V_BOOL(&persistent);
366 DWORD access = persist ? SERVICE_CHANGE_CONFIG : 0;
367 switch (control)
368 {
369 case 0:
371 break;
374 break;
375 }
376 SC_HANDLE hSvc;
378 if (SUCCEEDED(hr))
379 {
381 DWORD error, already;
382 if (control)
383 {
385 success = ControlService(hSvc, control, &ss);
387 already = ERROR_SERVICE_NOT_ACTIVE;
388 }
389 else
390 {
391 success = StartService(hSvc, 0, NULL);
394 }
395 hr = success ? S_OK : error == already ? S_FALSE : HRESULT_FROM_WIN32(error);
396 if (SUCCEEDED(hr) && persist)
397 {
401 }
402 CloseServiceHandle(hSvc);
403 }
404 return hr;
405}
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
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
#define success(from, fromstr, to, tostr)
#define ERROR_SERVICE_ALREADY_RUNNING
Definition: winerror.h:607
#define ERROR_SERVICE_NOT_ACTIVE
Definition: winerror.h:613
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define SERVICE_START
Definition: winsvc.h:57
#define SERVICE_NO_CHANGE
Definition: winsvc.h:20
#define SERVICE_CHANGE_CONFIG
Definition: winsvc.h:54
#define StartService
Definition: winsvc.h:585
#define SERVICE_STOP
Definition: winsvc.h:58
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
#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:34
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2391
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
LPCWSTR lpDirectory
Definition: shellapi.h:334
LPCWSTR lpParameters
Definition: shellapi.h:333
#define SW_SHOW
Definition: winuser.h:775

Referenced by OpenFolder().

◆ SHGetRestriction()

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

Definition at line 2740 of file ordinal.c.

2741{
2742#ifdef __REACTOS__
2744 DWORD dwSize, dwValue = 0;
2745
2746 TRACE("(%s, %s, %s)\n", debugstr_w(lpSubKey), debugstr_w(lpSubName), debugstr_w(lpValue));
2747
2748 if (!lpSubKey)
2749 lpSubKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies";
2750
2751 PathCombineW(szPath, lpSubKey, lpSubName);
2752
2753 dwSize = sizeof(dwValue);
2754 if (SHGetValueW(HKEY_LOCAL_MACHINE, szPath, lpValue, NULL, &dwValue, &dwSize) == ERROR_SUCCESS)
2755 return dwValue;
2756
2757 dwSize = sizeof(dwValue);
2758 SHGetValueW(HKEY_CURRENT_USER, szPath, lpValue, NULL, &dwValue, &dwSize);
2759 return dwValue;
2760#else
2761 DWORD retval, datsize = sizeof(retval);
2762 HKEY hKey;
2763
2764 if (!lpSubKey)
2765 lpSubKey = strRegistryPolicyW;
2766
2767 retval = RegOpenKeyW(HKEY_LOCAL_MACHINE, lpSubKey, &hKey);
2768 if (retval != ERROR_SUCCESS)
2769 retval = RegOpenKeyW(HKEY_CURRENT_USER, lpSubKey, &hKey);
2770 if (retval != ERROR_SUCCESS)
2771 return 0;
2772
2773 SHGetValueW(hKey, lpSubName, lpValue, NULL, &retval, &datsize);
2775 return retval;
2776#endif
2777}
#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
static const WCHAR strRegistryPolicyW[]
Definition: ordinal.c:2721
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
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:317
#define TRACE(s)
Definition: solgame.cpp:4
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
__wchar_t WCHAR
Definition: xmlstorage.h:180

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:3225
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:401

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

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )