Nuta
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować się zalogować lub zmienić katalog.
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować zmienić katalogi.
Poniższy przykład kodu przedstawia implementację modelu transferu opartego na strumieniu IStream.
MyWiaDriver::drvAcquireItemData(
BYTE *pWiasContext,
LONG lFlags,
PMINIDRV_TRANSFER_CONTEXT pmdtc,
LONG *plDevErrVal)
{
// Check what kind of data transfer is requested.
if (lFlags & WIA_MINIDRV_TRANSFER_DOWNLOAD)
{
// This transfer is a stream-based download.
IWiaMiniDrvTransferCallback *pTransferCallback = NULL;
hr = pmdtc->pIWiaMiniDrvCallBack->QueryInterface(IID_IWiaMiniDrvTransferCallback,
(void**) &pIWiaMiniDrvTransferCallback);
if (SUCCEEDED(hr))
{
IStream *pDestination = NULL;
// Get the destination stream from the client.
hr = pTransferCallback->GetNextStream(0,
bstrItemName,
bstrFullItemName,
&pDestination);
if (hr == S_OK)
{
BYTE *pBuffer = ...
ULONG ulBytesRead = 0;
// Read the next chunk of data into the buffer.
while(GetNextDataBand(pBuffer, &ulBytesRead))
{
// Write the data to the destination stream.
// The driver does not need to know what the
// destination is.
hr = pDestination->Write(...);
if (SUCCEEDED(hr))
{
// Send progress
hr = pTransferCallback->SendMessage(...)
}
else
{
// Take appropriate error action (for example, abort transfer)
}
}
}
}
.
.
.
}
}