SHGetRestriction

This function gets the value of a shell restriction given by its name and location within the registry.

Declaration

DWORD
SHGetRestriction (
    LPCWSTR lpKey,
    LPCWSTR lpSubKey,
    LPCWSTR lpValue);

Parameters

The lpKey argument provides a null-terminated string that names a key, to be interpreted relative to HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER. This argument may be NULL to stand for Software\Microsoft\Windows\CurrentVersion\Policies.

The lpSubKey argument provides a null-terminated string that names a subkey of the given key.

The lpValue argument provides a null-terminated string that names a DWORD value in the given subkey.

Return Value

The function returns four bytes of data for the given value, if found in the given key and subkey, else zero.

Behaviour

The function looks for the given key, subkey and value first in HKEY_LOCAL_MACHINE. If unsuccessful there, the function looks for the given key, subkey and value in HKEY_CURRENT_USER.

Note the return of zero on failure. Shell restrictions must be designed so that they are zero by default.

Availability

The SHGetRestriction function is exported from SHLWAPI as ordinal 271 in version 5.00 and higher.

Though this function dates from as long ago as 1999, it was still not documented by Microsoft in the MSDN Library at least as late as the CD edition dated January 2004.