IWiaItem2::GetExtension method

Gets the extension interfaces that might come with a Windows Image Acquisition (WIA) 2.0 device driver.

Syntax

HRESULT GetExtension(
  [in]  LONG   lFlags,
  [in]  BSTR   bstrName,
  [in]  REFIID riidExtensionInterface,
  [out] VOID   **ppOut
);

Parameters

lFlags [in]

Type: LONG

Currently unused. Should be set to zero.

bstrName [in]

Type: BSTR

Specifies the name of the extension that the calling application requires a pointer to.

SegmentationFilter

The segmentation filter extension. This is currently the only valid value for this parameter.

riidExtensionInterface [in]

Type: REFIID

Specifies the identifier of the extension interface.

ppOut [out]

Type: VOID**

Receives the address of a pointer to the extension interface.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

An application invokes this method to create an extension object implementing one of the WIA 2.0 driver extension interfaces. IWiaItem2::GetExtension stores the address of the extension object's extension interface in the riidExtensionInterface parameter. The application then uses the interface pointer to call its methods.

Applications must call the IUnknown::Release method on the interface pointers they receive through the riidExtensionInterface parameter.

Examples

CreateSegmentationFilter creates an instance of the driver's segmentation filter (IWiaSegmentationFilter) by calling IWiaItem2::GetExtension on the passed-in IWiaItem2 interface.

HRESULT
CreateSegmentationFilter(
   IWiaItem2               *pWiaItem2,
   IWiaSegmentationFilter  **ppSegmentationFilter)
{
   HRESULT                 hr         = S_OK;
   IWiaSegmentationFilter *pSegFilter = NULL;
    
   if (!pWiaItem2 || !ppSegmentationFilter)
   {
      hr = E_INVALIDARG;
   }

   if (SUCCEEDED(hr))
   {
      BSTR    bstrFilterString = SysAllocString(WIA_SEGMENTATION_FILTER_STR);

      if (bstrFilterString)
      {
         hr = pWiaItem2->GetExtension(0,
                                      bstrFilterString,
                                      IID_IWiaSegmentationFilter,
                                      (void**)&pSegFilter);
         SysFreeString(bstrFilterString);
         bstrFilterString = NULL;
      }
      else
      {
         hr = E_OUTOFMEMORY;
      }
   }

   if (SUCCEEDED(hr))
   {
     *ppSegmentationFilter = pSegFilter;
      pSegFilter = NULL;
   }
   return hr;
}

Requirements

Requirement Value
Minimum supported client
Windows Vista [desktop apps only]
Minimum supported server
Windows Server 2008 [desktop apps only]
Header
Wia.h
IDL
Wia.idl