SHOpenRegStream2 Function

Opens a registry value and supplies a stream that can be used to read from or write to the value. This function supersedes SHOpenRegStream.

Syntax

IStream *SHOpenRegStream2(      
    HKEY hkey,
    LPCTSTR pszSubkey,
    LPCTSTR pszValue,
    DWORD grfMode
);

Parameters

  • hkey
    [in] Required. The subtree, such as HKEY_LOCAL_MACHINE, that contains the value.
  • pszSubkey
    [in] Optional. Pointer to a null-terminated string that specifies the subkey that contains the value. This value can be NULL.
  • pszValue
    [in] Pointer to a null-terminated string that specifies the value to be accessed. This value can be NULL.
  • grfMode
    [in] The type of access for the stream. This can be one of the following values:
    • STGM_READ
      Open the stream for reading.
    • STGM_WRITE
      Open the stream for writing.
    • STGM_READWRITE
      Open the stream for reading and writing.

Return Value

Returns an IStream interface pointer if successful; otherwise, NULL. A NULL value can be caused by several situations, including an invalid hkey or pszSubkey, a subkey named by pszSubkey that does not exist, a caller without sufficient permissions to access the subkey, or an inability to open the stream.

Remarks

The calling application is responsible for calling the Release method of the returned object when that IStream object is no longer needed.

Function Information

Minimum DLL Version shlwapi.dll version 5.0 or later
Custom Implementation No
Header shlwapi.h
Import library shlwapi.lib
Minimum operating systems Windows 2000, Windows NT 4.0 with Internet Explorer 5, Windows 98, Windows 95 with Internet Explorer 5
Unicode Implemented as ANSI and Unicode versions.