/******************************************************************************
*
*  (C) COPYRIGHT MICROSOFT CORP., 1998-1999
*
*  TITLE:       WIA.idl
*
*  VERSION:     2.0
*
*  DATE:        6 Jan, 1998
*
*  DESCRIPTION:
*   IDL source for WIA device manager. The MIDL compiler generates
*   marshaling code and a type library from this file.
*
******************************************************************************/

interface IWiaDevMgr;
interface IWiaEventCallback;
interface IWiaDataCallback;
interface IWiaItem;
interface IWiaPropertyStorage;
interface IEnumWiaItem;
interface IEnumWIA_DEV_INFO;
interface IEnumWIA_DEV_CAPS;
interface IEnumWIA_FORMAT_INFO;
interface IStiDevice;

import "unknwn.idl";
import "oaidl.idl";
import "propidl.idl";
   
/*******************************************************************************
*
* Structures used by WIA
*
*******************************************************************************/

//
// Dither pattern specification structure used
// with WIA_DPS_DITHER_PATTERN_DATA
//

typedef struct _WIA_DITHER_PATTERN_DATA
{
                            LONG        lSize;
                            BSTR        bstrPatternName;
                            LONG        lPatternWidth;
                            LONG        lPatternLength;
                            LONG        cbPattern;
    [size_is(cbPattern)]    BYTE        *pbPattern;
} WIA_DITHER_PATTERN_DATA, *PWIA_DITHER_PATTERN_DATA;

typedef struct _WIA_PROPID_TO_NAME {
    PROPID      propid;
    LPOLESTR    pszName;
} WIA_PROPID_TO_NAME, *PWIA_PROPID_TO_NAME;

typedef struct _WIA_FORMAT_INFO
{
    GUID        guidFormatID;
    LONG        lTymed;
} WIA_FORMAT_INFO, *PWIA_FORMAT_INFO;

/*******************************************************************************
*
* Import header file which contains WIA constants and globals
*
*******************************************************************************/

cpp_quote("#include \"wiadef.h\"")

/*******************************************************************************
*
* WIA Device Manager Interface
*
*******************************************************************************/

[
    object,
    uuid(5eb2502a-8cf1-11d1-bf92-0060081ed811),
    helpstring("WIA Device Manager Interface"),
    pointer_default(unique)
]

interface IWiaDevMgr : IUnknown
{
    [helpstring("Create an WIA device information enumerator")]
    HRESULT EnumDeviceInfo(
        [in]            LONG                            lFlag,
        [out, retval]   IEnumWIA_DEV_INFO               **ppIEnum);

    //
    // Creates/loads device.
    //

    [local]
    HRESULT CreateDevice(
        [in]    BSTR                                    bstrDeviceID,
        [out]   IWiaItem                                **ppWiaItemRoot);
    
    [call_as(CreateDevice), helpstring("Create an WIA device object")]
    HRESULT LocalCreateDevice(
        [in]    BSTR                                    bstrDeviceID,
        [out]   IWiaItem                                **ppWiaItemRoot);
            

    //
    // Creates/loads user selected device. Client side only call.
    //

    [local]
    HRESULT SelectDeviceDlg(
        [in]            HWND                            hwndParent,
        [in]            LONG                            lDeviceType,
        [in]            LONG                            lFlags,
        [in,out]        BSTR                            *pbstrDeviceID,
        [out,retval]    IWiaItem                        **ppItemRoot);

    [call_as(SelectDeviceDlg),  helpstring("Present UI to select then create an WIA device")]
    HRESULT LocalSelectDeviceDlg(
        [in]            HWND                            hwndParent,
        [in]            LONG                            lDeviceType,
        [in]            LONG                            lFlags,
        [in,out]        BSTR                            *pbstrDeviceID,
        [out, retval]   IWiaItem                        **ppItemRoot);

    //
    // Returns the device ID of user selected device. Client side only call.
    //

    [local]
    HRESULT SelectDeviceDlgID(
        [in]            HWND                            hwndParent,
        [in]            LONG                            lDeviceType,
        [in]            LONG                            lFlags,
        [out, retval]   BSTR                            *pbstrDeviceID );

    [call_as(SelectDeviceDlgID), helpstring("Present UI to select then create an WIA device, returns BSTR")]
    HRESULT LocalSelectDeviceDlgID(
        [in]            HWND                            hwndParent,
        [in]            LONG                            lDeviceType,
        [in]            LONG                            lFlags,
        [out, retval]   BSTR                            *pbstrDeviceID );

    //
    // Creates/loads user selected device and gets image. Client side only call.
    //

    [local]
    HRESULT GetImageDlg(
        [in]            HWND                            hwndParent,
        [in]            LONG                            lDeviceType,
        [in]            LONG                            lFlags,
        [in]            LONG                            lIntent,
        [in]            IWiaItem                        *pItemRoot,
        [in]            BSTR                            bstrFilename,
        [in,out]        GUID                            *pguidFormat);

    [call_as(GetImageDlg), helpstring("Get an image to file")]
    HRESULT LocalGetImageDlg(
        [in]            HWND                            hwndParent,
        [in]            LONG                            lDeviceType,
        [in]            LONG                            lFlags,
        [in]            LONG                            lIntent,
        [in]            IWiaItem                        *pItemRoot,
        [in]            BSTR                            bstrFilename,
        [in,out]        GUID                            *pguidFormat);

    //
    //  Event registration
    //

    [local]
    HRESULT RegisterEventCallbackProgram(
        [in]            LONG                            lFlags,
        [in]            BSTR                            bstrDeviceID,
        [in]            const GUID                      *pEventGUID,
        [in]            BSTR                            bstrCommandline,
        [in]            BSTR                            bstrName,
        [in]            BSTR                            bstrDescription,
        [in]            BSTR                            bstrIcon);


    [call_as(RegisterEventCallbackProgram), helpstring("Register application launch")]
    HRESULT LocalRegisterEventCallbackProgram(
        [in]            LONG                            lFlags,
        [in]            BSTR                            bstrDeviceID,
        [in]            const GUID                      *pEventGUID,
        [in]            BSTR                            bstrCommandline,
        [in]            BSTR                            bstrName,
        [in]            BSTR                            bstrDescription,
        [in]            BSTR                            bstrIcon);

    [helpstring("Registers a WIA Event Callback")]
    HRESULT RegisterEventCallbackInterface(
        [in]            LONG                            lFlags,
        [in]            BSTR                            bstrDeviceID,
        [in]            const GUID                      *pEventGUID,
        [in,unique]     IWiaEventCallback               *pIWiaEventCallback,
        [out]           IUnknown                        **pEventObject);

    [local]
    HRESULT RegisterEventCallbackCLSID(
        [in]            LONG                            lFlags,
        [in]            BSTR                            bstrDeviceID,
        [in]            const GUID                      *pEventGUID,
        [in,unique]     const GUID                      *pClsID,
        [in]            BSTR                            bstrName,
        [in]            BSTR                            bstrDescription,
        [in]            BSTR                            bstrIcon);

    [call_as(RegisterEventCallbackCLSID), helpstring("Registers a WIA Event Callback via CLSID")]
    HRESULT LocalRegisterEventCallbackCLSID(
        [in]            LONG                            lFlags,
        [in]            BSTR                            bstrDeviceID,
        [in]            const GUID                      *pEventGUID,
        [in,unique]     const GUID                      *pClsID,
        [in]            BSTR                            bstrName,
        [in]            BSTR                            bstrDescription,
        [in]            BSTR                            bstrIcon);

    //
    // add either a non-pnp local Wia device or a network device
    //

    [helpstring("Present UI to add a WIA device")]
    HRESULT AddDeviceDlg(
        [in]            HWND                            hwndParent,
        [in]            LONG                            lFlags);

};

/*******************************************************************************
*
* WIA Device Information Enumeration Interface
*
*******************************************************************************/

[
    object,
    uuid(5e38b83c-8cf1-11d1-bf92-0060081ed811),
    helpstring("WIA Device Information Enumeration Interface"),
    pointer_default(unique)
]

interface IEnumWIA_DEV_INFO : IUnknown
{
    [local]
    HRESULT Next(
        [in]                                          ULONG                 celt,
        [out,size_is(celt), length_is(*pceltFetched)] IWiaPropertyStorage   **rgelt,
        [in,out,unique]                               ULONG*                pceltFetched);

    [call_as(Next), helpstring("Gets the next device information IWiaPropertyStorage object")]
    HRESULT RemoteNext(
        [in]                                          ULONG                 celt,
        [out,size_is(celt), length_is(*pceltFetched)] IWiaPropertyStorage   **rgelt,
        [in,out,unique]                               ULONG*                pceltFetched);

    [helpstring("Skips the next device information IWiaPropertyStorage object")]
    HRESULT Skip(
        [in]            ULONG                           celt);

    [helpstring("Resets to first device information IWiaPropertyStorage object")]
    HRESULT Reset(void);

    [helpstring("Clones this IEnumWIA_DEV_INFO object")]
    HRESULT Clone(
        [out]           IEnumWIA_DEV_INFO               **ppIEnum);

    [helpstring("Returns the number of elements stored by this enumerator")]
    HRESULT GetCount(
        [out]            ULONG                          *celt);
}


/**************************************************************************\
*
*   IWiaEventCallback Interface
*
*
*
*
*
*
* History:
*
*    2/11/1998
*
\**************************************************************************/

[
    object,
    uuid(ae6287b0-0084-11d2-973b-00a0c9068f2e),
    helpstring("WIA Event callback"),
    pointer_default(unique)
]

interface IWiaEventCallback : IUnknown
{
    //
    // WIA event notification
    //

    HRESULT ImageEventCallback(
        [in]            const GUID                      *pEventGUID,
        [in]            BSTR                            bstrEventDescription,
        [in]            BSTR                            bstrDeviceID,
        [in]            BSTR                            bstrDeviceDescription,
        [in]            DWORD                           dwDeviceType,
        [in]            BSTR                            bstrFullItemName,
        [in, out]       ULONG                           *pulEventType,
        [in]            ULONG                           ulReserved);
}

/**************************************************************************\
*
* WIA_DATA_CALLBACK_HEADER
*
*   lSize           - size of this structure
*   lFormat         - format of image
*   lBufferSize     - size of buffer needed for complete data transfer
*   lPageCount      - zero based count of total pages transfered
*
* History:
*
*   10/29/98
*
\**************************************************************************/

typedef struct _WIA_DATA_CALLBACK_HEADER{
    LONG        lSize;
    GUID        guidFormatID;
    LONG        lBufferSize;
    LONG        lPageCount;
}WIA_DATA_CALLBACK_HEADER,*PWIA_DATA_CALLBACK_HEADER;


/**************************************************************************\
*
*  IWiaDataCallback interface
*
*
*
*
*
* History:
*
*    10/29/1998 Original Version
*
\**************************************************************************/

[
    object,
    uuid(a558a866-a5b0-11d2-a08f-00c04f72dc3c),
    helpstring("WIA data callback"),
    pointer_default(unique)
]

interface IWiaDataCallback : IUnknown
{
    //
    // image transfer status
    //

    [local]
    HRESULT BandedDataCallback(
        [in]                      LONG        lMessage,
        [in]                      LONG        lStatus,
        [in]                      LONG        lPercentComplete,
        [in]                      LONG        lOffset,
        [in]                      LONG        lLength,
        [in]                      LONG        lReserved,
        [in]                      LONG        lResLength,
        [in,size_is(lResLength)]  BYTE        *pbBuffer);

    [call_as(BandedDataCallback) ,helpstring(" client data callback")]
    HRESULT RemoteBandedDataCallback(
        [in]                            LONG        lMessage,
        [in]                            LONG        lStatus,
        [in]                            LONG        lPercentComplete,
        [in]                            LONG        lOffset,
        [in]                            LONG        lLength,
        [in]                            LONG        lReserved,
        [in]                            LONG        lResLength,
        [in,size_is(lResLength),unique] BYTE        *pbBuffer);
}


/**************************************************************************\
*
* WIA_DATA_TRANSFER_INFO
*
*   ulSize           - Size of this structure
*   ulSection        - Section provided by the client, otherwise NULL
*   ulBufferSize     - Size of the buffer used in data transfer
*   bDoubleBuffer    - Indicate whether the client want to use double buffer
*   ulReserved1      - Must be ZERO
*   ulReserved2      - Must be ZERO
* History:
*
*   10/29/98
*
\**************************************************************************/

typedef struct _WIA_DATA_TRANSFER_INFO {
    ULONG       ulSize;
    ULONG       ulSection;
    ULONG       ulBufferSize;
    BOOL        bDoubleBuffer;
    ULONG       ulReserved1;
    ULONG       ulReserved2;
    ULONG       ulReserved3;
} WIA_DATA_TRANSFER_INFO, *PWIA_DATA_TRANSFER_INFO;

/**************************************************************************\
*
* WIA_EXTENDED_TRANSFER_INFO
*
*   ulSize              - Size of this structure.
*   ulMinBufferSize     - Minimum size of buffer that can be requested.
*   ulOptimalBufferSize - The device's optimal buffer size.
*   ulMaxBufferSize     - The maximum buffer size that can be requested.
*   ulNumBuffers        - Number of buffers the server may use.
*
* History:
*
*   01/20/2000
*
\**************************************************************************/

typedef struct _WIA_EXTENDED_TRANSFER_INFO {
    ULONG       ulSize;
    ULONG       ulMinBufferSize;
    ULONG       ulOptimalBufferSize;
    ULONG       ulMaxBufferSize;
    ULONG       ulNumBuffers;
} WIA_EXTENDED_TRANSFER_INFO, *PWIA_EXTENDED_TRANSFER_INFO;

/**************************************************************************\
*
* IWiaDataTransfer - Interface to use shared memory to transfer an image
*
*
*
*
*
*
*
* History:
*
*    4/1/1998
*
\**************************************************************************/

[
    object,
    uuid(a6cef998-a5b0-11d2-a08f-00c04f72dc3c),
    helpstring("WIA Data Transfer Interface"),
    pointer_default(unique)
]

interface IWiaDataTransfer : IUnknown
{
    [local]
    HRESULT idtGetData(
        [in,out]        LPSTGMEDIUM                     pMedium,
        [in,unique]     IWiaDataCallback               *pIWiaDataCallback);

    [call_as(idtGetData), helpstring("IDataObject style data transfer with progress callback")]
    HRESULT idtGetDataEx(
        [in,out]        LPSTGMEDIUM                     pMedium,
        [in,unique]     IWiaDataCallback               *pIWiaDataCallback);

    [local]
    HRESULT idtGetBandedData(
        [in,unique]     PWIA_DATA_TRANSFER_INFO         pWiaDataTransInfo,
        [in,unique]     IWiaDataCallback               *pIWiaDataCallback);

    [call_as(idtGetBandedData), helpstring("transfer image into a buffer")]
    HRESULT idtGetBandedDataEx(
        [in,unique]     PWIA_DATA_TRANSFER_INFO         pWiaDataTransInfo,
        [in,unique]     IWiaDataCallback               *pIWiaDataCallback);

    [helpstring("Check if format is supported")]
    HRESULT idtQueryGetData(
        [in,unique]     WIA_FORMAT_INFO*                pfe);

    [helpstring("Create format enumerator")]
    HRESULT idtEnumWIA_FORMAT_INFO(
        [out]           IEnumWIA_FORMAT_INFO            **ppEnum);

    [helpstring("Returns extended transfer information")]
    HRESULT idtGetExtendedTransferInfo(
        [out]           PWIA_EXTENDED_TRANSFER_INFO     pExtendedTransferInfo);
}

/*******************************************************************************
*
* IWiaItem Interface
*
*******************************************************************************/

[
    object,
    uuid(4db1ad10-3391-11d2-9a33-00c04fa36145),
    helpstring("WIA Device Item Interface"),
    pointer_default(unique)
]

interface IWiaItem : IUnknown
{
    [helpstring("Get item type")]
    HRESULT GetItemType(
        [out]   LONG                    *pItemType);

    [helpstring("Analyze an item")]
    HRESULT AnalyzeItem(
        [in]    LONG                    lFlags);

    [helpstring("Get item enumerator")]
    HRESULT EnumChildItems(
        [out]   IEnumWiaItem            **ppIEnumWiaItem);

    [helpstring("Delete an item")]
    HRESULT DeleteItem(
        [in]    LONG                    lFlags);

    [helpstring("Create a new child item")]
    HRESULT CreateChildItem(
        [in]    LONG                    lFlags,
        [in]    BSTR                    bstrItemName,
        [in]    BSTR                    bstrFullItemName,
        [out]   IWiaItem                **ppIWiaItem);

    [helpstring("Enumerate event info")]
    HRESULT EnumRegisterEventInfo(
        [in]    LONG                    lFlags,
        [in]    const GUID              *pEventGUID,
        [out]   IEnumWIA_DEV_CAPS       **ppIEnum);

    [helpstring("search for item by name")]
    HRESULT FindItemByName(
        [in]    LONG                    lFlags,
        [in]    BSTR                    bstrFullItemName,
        [out]   IWiaItem                **ppIWiaItem);

    // Client side only call.
    [local]
    HRESULT DeviceDlg(
        [in]    HWND                    hwndParent,
        [in]    LONG                    lFlags,
        [in]    LONG                    lIntent,
        [out]   LONG                    *plItemCount,
        [out]   IWiaItem                ***ppIWiaItem);

    [call_as(DeviceDlg), helpstring("Display device data acquistion UI")]
    HRESULT LocalDeviceDlg(
        [in]    HWND                    hwndParent,
        [in]    LONG                    lFlags,
        [in]    LONG                    lIntent,
        [out]   LONG                    *plItemCount,
        [out]   IWiaItem                ***pIWiaItem);

    [helpstring("Issue a device command")]
    HRESULT DeviceCommand(
        [in]            LONG            lFlags,
        [in]            const GUID      *pCmdGUID,
        [in, out]       IWiaItem        **pIWiaItem);

    [helpstring("Get device root item")]
    HRESULT GetRootItem(
        [out]           IWiaItem        **ppIWiaItem);

    [helpstring("Enumerate device events and commands")]
    HRESULT EnumDeviceCapabilities(
        [in]    LONG                    lFlags,
        [out]   IEnumWIA_DEV_CAPS       **ppIEnumWIA_DEV_CAPS);

    [helpstring("Dump private item data, debug only")]
    HRESULT DumpItemData(
        [out]           BSTR            *bstrData);

    [helpstring("Dump private driver item data, debug only")]
    HRESULT DumpDrvItemData(
        [out]           BSTR            *bstrData);

    [helpstring("Dump private tree item data, debug only")]
    HRESULT DumpTreeItemData(
        [out]           BSTR            *bstrData);

    [helpstring("Diagnostic")]
    HRESULT Diagnostic(
        [in]                    ULONG            ulSize,
        [in, size_is(ulSize)]   BYTE             *pBuffer);
};

/*******************************************************************************
*
* IWiaPropertyStorage Interface
*
*******************************************************************************/

[
    object,
    uuid(98B5E8A0-29CC-491a-AAC0-E6DB4FDCCEB6),
    helpstring("WIA Property Storage Interface"),
    pointer_default(unique)
]

interface IWiaPropertyStorage : IUnknown
{

/*
 * Should be inherited really
 */

    // When this IDL file is used for "IProp.dll" (the
    // standalone property set DLL), we must have local
    // and remotable routines (call_as routines are used
    // to remove BSTRs, which are not remotable with some
    // RPC run-times).
    //
    // For the remotable routines, we must use pointer
    // parameters (e.g. "*rgspec" rather than "rgspec[]")
    // so that the MIDL 2.0 compiler will generate an
    // interpereted proxy/stub, rather than inline.

#ifdef IPROPERTY_DLL
    [local]
#endif
    HRESULT ReadMultiple(
        [in]    ULONG                   cpspec,
        [in, size_is(cpspec)]
                const PROPSPEC          rgpspec[],
        [out, size_is(cpspec)]
                PROPVARIANT             rgpropvar[]
        );

#ifdef IPROPERTY_DLL
    [call_as(ReadMultiple)]
    HRESULT RemoteReadMultiple(
        [out]   BOOL                    *pfBstrPresent,
        [in]    ULONG                   cpspec,
        [in, size_is(cpspec)]
                const PROPSPEC          *rgpspec,
        [out, size_is(cpspec)]
                PROPVARIANT             *rgpropvar
        );
#endif

#ifdef IPROPERTY_DLL
    [local]
#endif
    HRESULT WriteMultiple(
        [in]    ULONG                   cpspec,
        [in, size_is(cpspec)]
                const PROPSPEC          rgpspec[],
        [in, size_is(cpspec)]
                const PROPVARIANT       rgpropvar[],
        [in]    PROPID                  propidNameFirst
        );

#ifdef IPROPERTY_DLL
    [call_as(WriteMultiple)]
    HRESULT RemoteWriteMultiple(
        [in]    BOOL                    fBstrPresent,
        [in]    ULONG                   cpspec,
        [in, size_is(cpspec)]
                const PROPSPEC          *rgpspec,
        [in, size_is(cpspec)]
                const PROPVARIANT       *rgpropvar,
        [in]    PROPID                  propidNameFirst
        );
#endif

#ifdef IPROPERTY_DLL
    [local]
#endif
    HRESULT DeleteMultiple(
        [in]    ULONG                   cpspec,
        [in, size_is(cpspec)]
                const PROPSPEC          rgpspec[]
        );

#ifdef IPROPERTY_DLL
    [call_as(DeleteMultiple)]
    HRESULT RemoteDeleteMultiple(
        [in]    ULONG                   cpspec,
        [in, size_is(cpspec)]
                const PROPSPEC          *rgpspec
        );
#endif

    HRESULT ReadPropertyNames(
        [in]    ULONG                   cpropid,
        [in, size_is(cpropid)]
                const PROPID            rgpropid[],
        [out, size_is(cpropid)]
                LPOLESTR                rglpwstrName[]
        );

    HRESULT WritePropertyNames(
        [in]    ULONG                   cpropid,
        [in, size_is(cpropid)]
                const PROPID            rgpropid[],
        [in, size_is(cpropid)]
                const LPOLESTR          rglpwstrName[]
        );

    HRESULT DeletePropertyNames(
        [in]    ULONG                   cpropid,
        [in, size_is(cpropid)]
                const PROPID            rgpropid[]
        );

    HRESULT Commit(
        [in]    DWORD                   grfCommitFlags
        );

    HRESULT Revert();

    HRESULT Enum(
        [out]   IEnumSTATPROPSTG **     ppenum
        );

    HRESULT SetTimes(
        [in]    FILETIME const *        pctime,
        [in]    FILETIME const *        patime,
        [in]    FILETIME const *        pmtime
        );

    HRESULT SetClass(
        [in]    REFCLSID                clsid
        );

    HRESULT Stat(
        [out]   STATPROPSETSTG *        pstatpsstg
        );

/*
 *=====================================================================*
 */

    [helpstring("Get property attribute information.")]
    HRESULT GetPropertyAttributes(
        [in]                    ULONG                   cpspec,
        [in, size_is(cpspec)]   PROPSPEC                rgpspec[],
        [out, size_is(cpspec)]  ULONG                   rgflags[],
        [out, size_is(cpspec)]  PROPVARIANT             rgpropvar[]);

    [helpstring("Returns the current number of properties in this property storage.")]
    HRESULT GetCount(
        [out]                   ULONG                   *pulNumProps);

    [helpstring("Get an items property stream")]
    HRESULT GetPropertyStream(
        [out]   GUID                   *pCompatibilityId,
        [out]   IStream                **ppIStream);

    [helpstring("Set an items property stream")]
    HRESULT SetPropertyStream(
        [in]            GUID                   *pCompatibilityId,
        [in, unique]    IStream                *pIStream);
};

/*******************************************************************************
*
* IEnumWiaItem Interface
*
*******************************************************************************/

[
    object,
    uuid(5e8383fc-3391-11d2-9a33-00c04fa36145),
    helpstring("WIA Device Class Item Enumeration Interface"),
    pointer_default(unique)
]

interface IEnumWiaItem : IUnknown
{
    [local]
    HRESULT Next(
        [in]                                           ULONG      celt,
        [out, size_is(celt), length_is(*pceltFetched)] IWiaItem **ppIWiaItem,
        [in, out, unique]                              ULONG     *pceltFetched);

    [call_as(Next), helpstring("Gets the next IWiaItem object")]
    HRESULT RemoteNext(
        [in]                                           ULONG      celt,
        [out, size_is(celt), length_is(*pceltFetched)] IWiaItem **ppIWiaItem,
        [in, out, unique]                              ULONG     *pceltFetched);

    [helpstring("Skips the next IWiaItem object")]
    HRESULT Skip(
        [in]    ULONG                   celt);

    [helpstring("Resets to first IWiaItem object")]
    HRESULT Reset(void);

    [helpstring("Clone IEnumWiaItem object")]
    HRESULT Clone(
        [out]   IEnumWiaItem            **ppIEnum);

    [helpstring("Returns the number of elements stored by this enumerator")]
    HRESULT GetCount(
        [out]   ULONG                   *celt);

}

/*******************************************************************************
*
*  WIA_DEV_CAP
*
*   WIA_DEV_CAP structure returns event and command information
*   for the IEnumWIA_DEV_CAPS Interface
*
*******************************************************************************/

typedef struct _WIA_DEV_CAP {
        GUID            guid;
        ULONG           ulFlags;   // Indicate the handler is default, etc
        BSTR            bstrName;
        BSTR            bstrDescription;
        BSTR            bstrIcon;
        BSTR            bstrCommandline;
} WIA_DEV_CAP, *PWIA_DEV_CAP, WIA_EVENT_HANDLER, *PWIA_EVENT_HANDLER;

/*******************************************************************************
*
* IEnumWIA_DEV_CAPS Interface
*
*******************************************************************************/

[
    object,
    uuid(1fcc4287-aca6-11d2-a093-00c04f72dc3c),
    helpstring("WIA_DEV_CAPS Enumeration Interface"),
    pointer_default(unique)
]

interface IEnumWIA_DEV_CAPS : IUnknown
{
    [local]
    HRESULT Next(
        [in]                                                      ULONG           celt,
        [out, size_is(celt), length_is(*pceltFetched)]            WIA_DEV_CAP     *rgelt,
        [in,out,unique]                                           ULONG           *pceltFetched);

    [call_as(Next), helpstring("Gets the next WIA_DEV_CAPS")]
    HRESULT RemoteNext(
        [in]                                                      ULONG           celt,
        [out, size_is(celt), length_is(*pceltFetched)]            WIA_DEV_CAP     *rgelt,
        [in,out,unique]                                           ULONG           *pceltFetched);


    [helpstring("Skips the next WIA_DEV_CAPS")]
    HRESULT Skip(
        [in]                            ULONG                   celt);

    [helpstring("Resets to first WIA_DEV_CAPS")]
    HRESULT Reset(void);

    [helpstring("Clone IEnumWIA_DEV_CAPS object")]
    HRESULT Clone(
        [out]                           IEnumWIA_DEV_CAPS       **ppIEnum);

    [helpstring("Returns the number of elements stored by this enumerator")]
    HRESULT GetCount(
        [out]                           ULONG                   *pcelt);

}

/*******************************************************************************
*
* IEnumWIA_FORMAT_INF Interface
*
*******************************************************************************/

[
    object,
    uuid(81BEFC5B-656D-44f1-B24C-D41D51B4DC81),
    helpstring("WIA_FORMAT_INFO Enumeration Interface"),
    pointer_default(unique)
]

interface IEnumWIA_FORMAT_INFO : IUnknown
{
    [local]
    HRESULT Next(
        [in]                                                    ULONG           celt,
        [out, size_is(celt), length_is(*pceltFetched)]          WIA_FORMAT_INFO *rgelt,
        [in,out,unique]                                         ULONG           *pceltFetched);

    [call_as(Next), helpstring("Gets the next WIA_FORMAT_INFO")]
    HRESULT RemoteNext(
        [in]                                                    ULONG           celt,
        [out, size_is(celt), length_is(*pceltFetched)]          WIA_FORMAT_INFO *rgelt,
        [in,out,unique]                                         ULONG           *pceltFetched);

    [helpstring("Skips the next WIA_FORMAT_INFO")]
    HRESULT Skip(
        [in]                            ULONG                   celt);

    [helpstring("Resets to first WIA_FORMAT_INFO")]
    HRESULT Reset(void);

    [helpstring("Clone IEnumWIA_FORMAT_INFO object")]
    HRESULT Clone(
        [out]                           IEnumWIA_FORMAT_INFO    **ppIEnum);

    [helpstring("Returns the number of elements stored by this enumerator")]
    HRESULT GetCount(
        [out]                           ULONG                   *pcelt);

}

/*******************************************************************************
*
* WIA Logging Interface
*
*******************************************************************************/

[
    object,
    uuid(A00C10B6-82A1-452f-8B6C-86062AAD6890),
    helpstring("WIA Logging Interface"),
    pointer_default(unique)
]

interface IWiaLog : IUnknown
{
    [helpstring("Initialize Logging object")]
    HRESULT InitializeLog(
        [in]            LONG                            hInstance);

    [helpstring("Write ERRROR Information to log file, Translating HRESULT to error string")]
    HRESULT hResult(
        [in]            HRESULT                         hResult);

    [helpstring("Write TRACE,ERROR,WARNING, etc.. Information to log file, using service Resource ID")]
    HRESULT Log(
        [in]            LONG                            lFlags,
        [in]            LONG                            lResID,
        [in]            LONG                            lDetail,
        [in]            BSTR                            bstrText);
};


/*******************************************************************************
*
* WIA Extended Logging Interface
*
*******************************************************************************/

[
   object,
   uuid(AF1F22AC-7A40-4787-B421-AEb47A1FBD0B),
   helpstring("WIA (Extended) Logging Interface"),
   pointer_default(unique)
]

interface IWiaLogEx : IUnknown
{
    [helpstring("Initialize Logging object")]
    HRESULT InitializeLogEx(
        [in]            BYTE                            *hInstance);
    
    [helpstring("Write ERRROR Information to log file, Translating HRESULT to error string")]
    HRESULT hResult(
        [in]            HRESULT                         hResult);

    [helpstring("Write information to log - compatible with IWiaLog::Log(...)")]
    HRESULT Log(
        [in]            LONG                            lFlags,
        [in]            LONG                            lResID,
        [in]            LONG                            lDetail,
        [in]            BSTR                            bstrText);
    
    [helpstring("Write ERRROR Information to log file, Translating HRESULT to error string")]
    HRESULT hResultEx(
        [in]            LONG                            lMethodId,
        [in]            HRESULT                         hResult);

    [helpstring("Write TRACE,ERROR,WARNING, etc.. Information to log file, using service Resource ID")]
    HRESULT LogEx(
        [in]            LONG                            lMethodId,
        [in]            LONG                            lFlags,
        [in]            LONG                            lResID,
        [in]            LONG                            lDetail,
        [in]            BSTR                            bstrText);

};

/*******************************************************************************
*
* WiaDevMgr General Notification Interface
*
*******************************************************************************/
[
    object,
    uuid(70681EA0-E7BF-4291-9FB1-4E8813A3F78E),
    helpstring("WiaDevMgr Notification Interface"),
    pointer_default(unique)
]

interface IWiaNotifyDevMgr : IUnknown
{
    [helpstring("Notify of new device arrival")]
    HRESULT NewDeviceArrival();
};

[
   object,
   uuid(6291ef2c-36ef-4532-876a-8e132593778d),
   helpstring("WIA Item extras interface"),
   pointer_default(unique)
]

interface IWiaItemExtras : IUnknown
{
    [helpstring("Retrieve extended error string")]
    HRESULT GetExtendedErrorInfo([out] BSTR *bstrErrorText);

    [helpstring("Escape to driver")]
    HRESULT Escape([in] DWORD dwEscapeCode,
                   [in, size_is(cbInDataSize)] BYTE * lpInData,
                   [in] DWORD cbInDataSize,
                   [out, size_is(dwOutDataSize), length_is((pdwActualDataSize) ? *pdwActualDataSize : dwOutDataSize)] BYTE * pOutData,
                   [in] DWORD dwOutDataSize,
                   [out] DWORD *pdwActualDataSize);

    [helpstring("Cancel pending IO")]
    HRESULT CancelPendingIO();
}

/*******************************************************************************
*
*               C O M P O N E N T    D E S C R I P T I O N S
*
*******************************************************************************/

[
    uuid(99f74582-8cf1-11d1-bf92-0060081ed811),
        version(1.0),
    helpstring("WIA Type Library")
]

library WiaDevMgr
{
        importlib("stdole32.tlb") ;

        // WIA Device Manager
        [
        uuid(a1f4e726-8cf1-11d1-bf92-0060081ed811),
        helpstring("WIA Device Manager")
        ]

    coclass WiaDevMgr
        {
        [default] interface IWiaDevMgr;
        };

        // WIA Logging
        [
        uuid(A1E75357-881A-419e-83E2-BB16DB197C68),
        helpstring("WIA Logging")
        ]

    coclass WiaLog
        {
        interface IWiaLog;
        };

};

