The following code illustrates how to install or remove a specific stream protocol for a stream handler.
#include "os2.h" #include "os2me.h" ULONG ulRC; /* Error return code */ HID hidTarget; /* Target handler ID */ SPCBKEY spcbkey; /* Data type to stream */ SPCB spcb; . . . /*-------------------------------------------------------------------*/ /* Get the stream handler ID (hidSource) for the file stream handler */ /* using SpiGetHandler. */ /*-------------------------------------------------------------------*/ . . . /*--------------------------------------------------------------------*/ /* Get the stream protocol control block (SPCB) for the given stream */ /* handler and SPCB key. */ /*--------------------------------------------------------------------*/ spcbkey.ulDataType = DATATYPE_WAVEFORM; spcbkey.ulDataSubType = WAVE_FORMAT_4S16; spcbkey.ulIntKey = 0; if (ulRC = SpiGetProtocol( hidTarget, &spcbkey, &spcb)) return(ulRC); /* Error! */ . . . /*----------------------------------------------------------------*/ /* Install a stream protocol control block (SPCB) for the given */ /* handler and SPCB key. */ /*----------------------------------------------------------------*/ spcbkey.ulIntKey = 1; /* Must be a unique number (non-zero) */ spcb.spcbkey.ulIntkey = 1;/* Ensure that the keys match. */ spcb.ulMaxBuf = 5; /* Change number of stream buffers. */ spcb.ulBufSize = 32768; /* Change size of buffers. */ if (ulRC = SpiInstallProtocol( hidTarget, &spcbkey, &spcb, SPI_INSTALL_PROTOCOL)) return(ulRC); /* Error! */