SKGetValueW

This function queries a value in a subkey of a shell key.

Declaration

HRESULT
SKGetValueW (
    SHELLKEY nShellKey,
    LPCWSTR pszSubKey,
    LPCWSTR pszValue,
    LPDWORD pdwType,
    LPVOID pvData,
    LPDWORD pcbData);

Parameters

The nShellKey argument specifies the shell key as a constant from the SHELLKEY enumeration.

The pszSubKey argument provides the address of a null-terminated string that names the subkey, or is NULL for the shell key itself.

The pszValue argument provides the address of a null-terminated string that names the value, or is NULL for the default value.

The pdwType argument provides the address of a variable that is to receive the data type, e.g., REG_SZ or REG_DWORD. This argument can be NULL to mean that the data type is not wanted.

The pvData argument provides the address of a buffer that is to receive the data. This argument can be NULL to mean that the data is not wanted.

The pcbData argument provides the address of a variable that plays two roles. On input, the variable provides the size of the buffer, in bytes, but is ignored if pvData is NULL. On output, the variable receives the size of the data, in bytes. This argument can be NULL if pvData is NULL or to mean that the buffer size is zero.

Return Value

The function returns zero for success, else an error code.

Of particular interest are the cases when the value is accessible but has more data than can fit in the given buffer, including because there is no buffer:

Behaviour

The function opens the given subkey of the selected shell key (using SHGetShellKeyEx, asking for read access), queries the value for its data (using SHQueryValueExW), and closes the subkey.

Variations

In builds before Windows Vista, the subkey is opened by using SHGetShellKey.

Availability

The SKGetValueW function is exported from SHLWAPI as ordinal 516 in version 6.00 and higher.

Though this function dates from 2001, it was still not documented by Microsoft as late as the January 2007 edition of the Windows Vista Software Development Kit (SDK).