ReactOS 0.4.16-dev-109-gf4cb10f
SHRestricted.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Test for SHRestricted
5 * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7
8#include "shelltest.h"
9#include <versionhelpers.h>
10
11#define REGKEY_POLICIES L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies"
12#define REGKEY_POLICIES_EXPLORER REGKEY_POLICIES L"\\Explorer"
13
16
17#define DELETE_VALUE(hBaseKey) \
18 SHDeleteValueW((hBaseKey), REGKEY_POLICIES_EXPLORER, L"NoRun")
19
20#define SET_VALUE(hBaseKey, value) do { \
21 dwValue = (value); \
22 SHSetValueW((hBaseKey), REGKEY_POLICIES_EXPLORER, L"NoRun", \
23 REG_DWORD, &dwValue, sizeof(dwValue)); \
24} while (0)
25
26static VOID
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}
79
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)
#define SET_VALUE(hBaseKey, value)
BOOL(WINAPI * FN_SHSettingsChanged)(LPCVOID unused, LPCVOID inpRegKey)
#define DELETE_VALUE(hBaseKey)
DWORD(WINAPI * FN_SHRestricted)(RESTRICTIONS rest)
#define ok_long(expression, result)
Definition: atltest.h:133
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
unsigned long DWORD
Definition: ntddk_ex.h:95
WORD unused[29]
Definition: crypt.c:1155
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
#define L(x)
Definition: ntvdm.h:50
RESTRICTIONS
Definition: shlobj.h:1641
@ REST_NORUN
Definition: shlobj.h:1643
DWORD WINAPI SHRestricted(RESTRICTIONS rest)
Definition: shpolicy.c:150
VERSIONHELPERAPI IsWindowsVistaOrGreater()
CONST void * LPCVOID
Definition: windef.h:191
#define WINAPI
Definition: msvc.h:6
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581