IStreamBufferInitialize::SetHKEY Method
This topic applies only to Windows XP Service Pack 1 or later.
The SetHKEY method sets the registry key where the stream buffer object stores its configuration information.
Syntax
HRESULT SetHKEY(
[in] HKEY hkeyRoot
);
Parameters
- hkeyRoot [in]
Handle to the registry key.
Return Value
Returns an HRESULT. Possible values include those in the following table.
Return code | Description |
---|---|
S_OK |
The method succeeded. |
E_UNEXPECTED |
SetHKEY was called on a filter after it initialized internally. |
Remarks
This method enables an application to specify a registry key where the stream buffer objects will save configuration information, including the location of the backing files, the number of backing files, and their size.
You must call this method before the object is initialized, either explicitly or implicitly. For the Stream Buffer Sink filter, call the method before the profile is locked. For the Stream Buffer Source filter, call the method before setting the source file name.
To use this method, do the following:
- Create a new registry key or open an existing key.
- Create an instance of the StreamBufferConfig object.
- Query the StreamBufferConfig object for the IStreamBufferInitialize interface.
- Call SetHKey on the StreamBufferConfig object, with a handle to the registry key.
- Optionally, call IStreamBufferConfigure methods to modify the configuration information that will be stored in the registry key.
- Call SetHKey on the Stream Buffer Source filter and the Stream Buffer Sink filter, using the same registry key.
The application is responsible for ensuring that the user has read/write permissions for the registry key.
The caller may release the registry key handle after calling this method.
Examples
The following code shows how to configure the backing file directory. Error checking is omitted for brevity.
// Create the StreamBufferConfig object.
CComPtr<IStreamBufferConfigure> pConfig;
hr = pConfig.CoCreateInstance(CLSID_StreamBufferConfig);
// Create a new registry key to hold our settings.
HKEY hkey = 0;
long lRes = RegCreateKey(HKEY_LOCAL_MACHINE,
TEXT("SOFTWARE\\MyStreamBufferKey"), &hkey);
// Set the registry key.
CComPtr<IStreamBufferInitialize> pInit;
hr = pConfig.QueryInterface(&pInit);
hr = pInit->SetHKEY(hkey);
pInit.Release();
// Set the backing file directory.
hr = pConfig->SetDirectory(L"C:\\MyDirectory");
// Create the Stream Buffer Sink filter and set the registry key.
CComPtr<IStreamBufferSink> pSink;
hr = pSink.CoCreateInstance(CLSID_StreamBufferSink);
hr = pSink.QueryInterface(&pInit);
hr = pInit->SetHKEY(hkey);
pInit.Release();
// Create the Stream Buffer Source filter and set the registry key.
CComPtr<IStreamBufferSource> pSource;
hr = pSource.CoCreateInstance(CLSID_StreamBufferSource);
hr = pSource.QueryInterface(&pInit);
hr = pInit->SetHKEY(hkey);
Requirements
Header | Declared in Sbe.h. |
See Also
IStreamBufferInitialize Interface
Send comments about this topic to Microsoft
Build date: 12/4/2008