ReactOS 0.4.15-dev-7961-gdcf9eb0
SHGetRestriction.c File Reference
#include <apitest.h>
#include <shlwapi.h>
Include dependency graph for SHGetRestriction.c:

Go to the source code of this file.

Classes

struct  tagTEST_ENTRY
 

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_SHGetRestriction) (LPCWSTR lpSubKey, LPCWSTR lpSubName, LPCWSTR lpValue)
 
typedef BOOL(WINAPIFN_SHSettingsChanged) (LPCVOID unused, LPCVOID inpRegKey)
 
typedef struct tagTEST_ENTRY TEST_ENTRY
 
typedef struct tagTEST_ENTRYPTEST_ENTRY
 

Functions

static DWORD Candidate_SHGetRestriction (LPCWSTR lpSubKey, LPCWSTR lpSubName, LPCWSTR lpValue)
 
static void TEST_DoEntry (const TEST_ENTRY *entry, FN_SHGetRestriction fnSHGetRestriction)
 
static void TEST_SHGetRestriction_Stage (INT iStage, FN_SHGetRestriction fnSHGetRestriction)
 
 START_TEST (SHGetRestriction)
 

Variables

static const TEST_ENTRY s_Entries []
 

Macro Definition Documentation

◆ DELETE_VALUE

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

Definition at line 66 of file SHGetRestriction.c.

◆ REGKEY_POLICIES

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

Definition at line 11 of file SHGetRestriction.c.

◆ REGKEY_POLICIES_EXPLORER

#define REGKEY_POLICIES_EXPLORER   REGKEY_POLICIES L"\\Explorer"

Definition at line 12 of file SHGetRestriction.c.

◆ 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 69 of file SHGetRestriction.c.

Typedef Documentation

◆ FN_SHGetRestriction

typedef DWORD(WINAPI * FN_SHGetRestriction) (LPCWSTR lpSubKey, LPCWSTR lpSubName, LPCWSTR lpValue)

Definition at line 14 of file SHGetRestriction.c.

◆ FN_SHSettingsChanged

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

Definition at line 15 of file SHGetRestriction.c.

◆ PTEST_ENTRY

◆ TEST_ENTRY

Function Documentation

◆ Candidate_SHGetRestriction()

static DWORD Candidate_SHGetRestriction ( LPCWSTR  lpSubKey,
LPCWSTR  lpSubName,
LPCWSTR  lpValue 
)
static

Definition at line 18 of file SHGetRestriction.c.

19{
21 DWORD cbValue, dwValue = 0;
22
23 if (!lpSubKey)
24 lpSubKey = REGKEY_POLICIES;
25
26 PathCombineW(szPath, lpSubKey, lpSubName);
27
28 cbValue = sizeof(dwValue);
29 if (SHGetValueW(HKEY_LOCAL_MACHINE, szPath, lpValue, NULL, &dwValue, &cbValue) == ERROR_SUCCESS)
30 return dwValue;
31
32 cbValue = sizeof(dwValue);
33 SHGetValueW(HKEY_CURRENT_USER, szPath, lpValue, NULL, &dwValue, &cbValue);
34 return dwValue;
35}
#define REGKEY_POLICIES
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
unsigned long DWORD
Definition: ntddk_ex.h:95
LPCWSTR szPath
Definition: env.c:37
#define PathCombineW
Definition: pathcch.h:317
#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 TEST_DoEntry().

◆ START_TEST()

START_TEST ( SHGetRestriction  )

Definition at line 123 of file SHGetRestriction.c.

124{
125 HMODULE hSHLWAPI = LoadLibraryW(L"shlwapi.dll");
127 INT iStage;
128
129 if (fn)
130 {
131 for (iStage = 0; iStage < 7; ++iStage)
133
136 }
137 else
138 {
139 skip("SHGetRestriction not found\n");
140 }
141
142 FreeLibrary(hSHLWAPI);
143}
static void TEST_SHGetRestriction_Stage(INT iStage, FN_SHGetRestriction fnSHGetRestriction)
DWORD(WINAPI * FN_SHGetRestriction)(LPCWSTR lpSubKey, LPCWSTR lpSubName, LPCWSTR lpValue)
#define DELETE_VALUE(hBaseKey)
#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
int32_t INT
Definition: typedefs.h:58
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581

◆ TEST_DoEntry()

static void TEST_DoEntry ( const TEST_ENTRY entry,
FN_SHGetRestriction  fnSHGetRestriction 
)
static

Definition at line 58 of file SHGetRestriction.c.

59{
60 DWORD value1 = fnSHGetRestriction(NULL, entry->lpSubName, entry->lpValue);
61 DWORD value2 = Candidate_SHGetRestriction(NULL, entry->lpSubName, entry->lpValue);
62 //trace("%ld vs %ld\n", value1, value2);
63 ok_long(value1, value2);
64}
static DWORD Candidate_SHGetRestriction(LPCWSTR lpSubKey, LPCWSTR lpSubName, LPCWSTR lpValue)
#define ok_long(expression, result)
Definition: atltest.h:133
uint32_t entry
Definition: isohybrid.c:63

Referenced by TEST_SHGetRestriction_Stage().

◆ TEST_SHGetRestriction_Stage()

static void TEST_SHGetRestriction_Stage ( INT  iStage,
FN_SHGetRestriction  fnSHGetRestriction 
)
static

Definition at line 76 of file SHGetRestriction.c.

79{
80 size_t iItem;
81 DWORD dwValue;
82
83 trace("Stage #%d\n", iStage);
84
85 switch (iStage)
86 {
87 case 0:
90 break;
91 case 1:
94 break;
95 case 2:
98 break;
99 case 3:
102 break;
103 case 4:
106 break;
107 case 5:
110 break;
111 case 6:
114 break;
115 }
116
117 for (iItem = 0; iItem < _countof(s_Entries); ++iItem)
118 {
119 TEST_DoEntry(&s_Entries[iItem], fnSHGetRestriction);
120 }
121}
static const TEST_ENTRY s_Entries[]
#define SET_VALUE(hBaseKey, value)
static void TEST_DoEntry(const TEST_ENTRY *entry, FN_SHGetRestriction fnSHGetRestriction)
#define trace
Definition: atltest.h:70
#define _countof(array)
Definition: sndvol32.h:68

Referenced by START_TEST().

Variable Documentation

◆ s_Entries

const TEST_ENTRY s_Entries[]
static
Initial value:
=
{
{ L"Explorer", L"NoRun" },
{ L"Explorer", L"ForceActiveDesktopOn" },
{ L"Explorer", L"NoActiveDesktop" },
{ L"Explorer", L"NoDisconnect" },
{ L"Explorer", L"NoRecentDocsHistory" },
{ L"Explorer", L"NoDriveTypeAutoRun" },
{ L"Explorer", L"NoSimpleStartMenu" },
{ L"System", L"DontDisplayLastUserName" },
{ L"System", L"ShutdownWithoutLogon" },
{ L"System", L"UndockWithoutLogon" },
}

Definition at line 43 of file SHGetRestriction.c.

Referenced by TEST_SHGetRestriction_Stage().