ReactOS 0.4.15-dev-8231-g29a56f3
SHRestricted.cpp File Reference
#include "shelltest.h"
#include <versionhelpers.h>
Include dependency graph for SHRestricted.cpp:

Go to the source code of this file.

Macros

#define REGKEY_POLICIES   L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies"
 
#define REGKEY_POLICIES_EXPLORER   REGKEY_POLICIES L"\\Explorer"
 
#define DELETE_VALUE(hBaseKey)    SHDeleteValueW((hBaseKey), REGKEY_POLICIES_EXPLORER, L"NoRun")
 
#define SET_VALUE(hBaseKey, value)
 

Typedefs

typedef DWORD(WINAPIFN_SHRestricted) (RESTRICTIONS rest)
 
typedef BOOL(WINAPIFN_SHSettingsChanged) (LPCVOID unused, LPCVOID inpRegKey)
 

Functions

static VOID TEST_SHRestricted (FN_SHRestricted fnGetValue, FN_SHSettingsChanged fnRefresh)
 
 START_TEST (SHRestricted)
 

Macro Definition Documentation

◆ DELETE_VALUE

#define DELETE_VALUE (   hBaseKey)     SHDeleteValueW((hBaseKey), REGKEY_POLICIES_EXPLORER, L"NoRun")

Definition at line 17 of file SHRestricted.cpp.

◆ REGKEY_POLICIES

#define REGKEY_POLICIES   L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies"

Definition at line 11 of file SHRestricted.cpp.

◆ REGKEY_POLICIES_EXPLORER

#define REGKEY_POLICIES_EXPLORER   REGKEY_POLICIES L"\\Explorer"

Definition at line 12 of file SHRestricted.cpp.

◆ SET_VALUE

#define SET_VALUE (   hBaseKey,
  value 
)
Value:
do { \
dwValue = (value); \
SHSetValueW((hBaseKey), REGKEY_POLICIES_EXPLORER, L"NoRun", \
REG_DWORD, &dwValue, sizeof(dwValue)); \
} while (0)
#define REGKEY_POLICIES_EXPLORER
#define L(x)
Definition: ntvdm.h:50
#define REG_DWORD
Definition: sdbapi.c:596
Definition: pdh_main.c:94

Definition at line 20 of file SHRestricted.cpp.

Typedef Documentation

◆ FN_SHRestricted

typedef DWORD(WINAPI * FN_SHRestricted) (RESTRICTIONS rest)

Definition at line 14 of file SHRestricted.cpp.

◆ FN_SHSettingsChanged

typedef BOOL(WINAPI * FN_SHSettingsChanged) (LPCVOID unused, LPCVOID inpRegKey)

Definition at line 15 of file SHRestricted.cpp.

Function Documentation

◆ START_TEST()

START_TEST ( SHRestricted  )

Definition at line 80 of file SHRestricted.cpp.

81{
83 {
84 skip("Vista+");
85 return;
86 }
87
88 HMODULE hSHELL32 = LoadLibraryW(L"shell32.dll");
89 FN_SHRestricted fnGetValue;
90 FN_SHSettingsChanged fnRefresh;
91
92 fnGetValue = (FN_SHRestricted)GetProcAddress(hSHELL32, MAKEINTRESOURCEA(100));
93 fnRefresh = (FN_SHSettingsChanged)GetProcAddress(hSHELL32, MAKEINTRESOURCEA(244));
94
95 if (fnGetValue && fnRefresh)
96 {
97 TEST_SHRestricted(fnGetValue, fnRefresh);
98 }
99 else
100 {
101 if (!fnGetValue)
102 skip("SHRestricted not found\n");
103 if (!fnRefresh)
104 skip("SHSettingsChanged not found\n");
105 }
106
107 FreeLibrary(hSHELL32);
108}
static VOID TEST_SHRestricted(FN_SHRestricted fnGetValue, FN_SHSettingsChanged fnRefresh)
BOOL(WINAPI * FN_SHSettingsChanged)(LPCVOID unused, LPCVOID inpRegKey)
DWORD(WINAPI * FN_SHRestricted)(RESTRICTIONS rest)
#define skip(...)
Definition: atltest.h:64
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
VERSIONHELPERAPI IsWindowsVistaOrGreater()
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581

◆ TEST_SHRestricted()

static VOID TEST_SHRestricted ( FN_SHRestricted  fnGetValue,
FN_SHSettingsChanged  fnRefresh 
)
static

Definition at line 27 of file SHRestricted.cpp.

28{
29 DWORD dwValue;
30
33
34 fnRefresh(NULL, NULL);
35 ok_long(fnGetValue(REST_NORUN), 0);
36
39
40 ok_long(fnGetValue(REST_NORUN), 0);
41 fnRefresh(NULL, NULL);
42 ok_long(fnGetValue(REST_NORUN), 0);
43
46
47 ok_long(fnGetValue(REST_NORUN), 0);
48 fnRefresh(NULL, NULL);
49 ok_long(fnGetValue(REST_NORUN), 1);
50
53
54 ok_long(fnGetValue(REST_NORUN), 1);
55 fnRefresh(NULL, NULL);
56 ok_long(fnGetValue(REST_NORUN), 0);
57
60
61 ok_long(fnGetValue(REST_NORUN), 0);
62 fnRefresh(NULL, NULL);
63 ok_long(fnGetValue(REST_NORUN), 1);
64
67
68 ok_long(fnGetValue(REST_NORUN), 1);
69 fnRefresh(NULL, NULL);
70 ok_long(fnGetValue(REST_NORUN), 1);
71
74
75 ok_long(fnGetValue(REST_NORUN), 1);
76 fnRefresh(NULL, NULL);
77 ok_long(fnGetValue(REST_NORUN), 0);
78}
#define SET_VALUE(hBaseKey, value)
#define DELETE_VALUE(hBaseKey)
#define ok_long(expression, result)
Definition: atltest.h:133
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
@ REST_NORUN
Definition: shlobj.h:1636
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by START_TEST().