' ########################################################################################
' Microsoft Windows
' File: sti.inc
' Contents: This module contains the user mode still image APIs in COM format
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_Sti_PBI)
#DEFINE PBX_Sti_PBI
%EQUATE `STI_INC = 1
' //
' // Set packing
' //
'#include <pshpack8.h>
' //
' // Only use UNICODE STI interfaces
' //
%EQUATE `STI_UNICODE = 1
' //
' // Include COM definitions
' //
#INCLUDE ONCE "Legacy/COM/Ole2.inc"
#INCLUDE ONCE "Legacy/System/ObjBase.inc"
#INCLUDE ONCE "Legacy/System/Stireg.inc"
#INCLUDE ONCE "Legacy/System/Stierr.inc"
'/*
' * Class IID's
' */
$CLSID_Sti = GUID$("{B323F8E0-2E68-11D0-90EA-00AA0060F86C}")
'/*
' * Interface IID's
' */
$IID_IStillImageW = GUID$("{641BD880-2DC8-11D0-90EA-00AA0060F86C}")
$IID_IStillImageA = GUID$("{A7B1F740-1D7F-11D1-ACA9-00A02438AD48}")
$IID_IStillImage = GUID$("{A7B1F740-1D7F-11D1-ACA9-00A02438AD48}")
$IID_IStiDevice = GUID$("{6CFA5A80-2DC8-11D0-90EA-00AA0060F86C}")
'/*
' * Standard event GUIDs
' */
$GUID_DeviceArrivedLaunch = GUID$("{740D9EE6-70F1-11d1-AD10-00A02438AD48}")
$GUID_ScanImage = GUID$("{A6C5A715-8C6E-11d2-977A-0000F87A926F}")
$GUID_ScanPrintImage = GUID$("{B441F425-8C6E-11d2-977A-0000F87A926F}")
$GUID_ScanFaxImage = GUID$("{C00EB793-8C6E-11d2-977A-0000F87A926F}")
$GUID_STIUserDefined1 = GUID$("{C00EB795-8C6E-11d2-977A-0000F87A926F}")
$GUID_STIUserDefined2 = GUID$("{C77AE9C5-8C6E-11d2-977A-0000F87A926F}")
$GUID_STIUserDefined3 = GUID$("{C77AE9C6-8C6E-11d2-977A-0000F87A926F}")
' //
' // Generic constants and definitions
' //
%EQUATE `STI_VERSION_FLAG_MASK = &Hff000000
%EQUATE `STI_VERSION_FLAG_UNICODE = &H01000000
'#define GET_STIVER_MAJOR(dwVersion) (HIWORD(dwVersion) & ~STI_VERSION_FLAG_MASK)
'#define GET_STIVER_MINOR(dwVersion) LOWORD(dwVersion)
MACRO GET_STIVER_MAJOR(dwVersion) = (HI(WORD, dwVersion) AND NOT %STI_VERSION_FLAG_MASK)
MACRO GET_STIVER_MINOR(dwVersion) = LO(WORD, dwVersion)
%EQUATE `STI_VERSION_REAL = &H00000002
'#if (_WIN32_WINNT >= 0x0600) // Windows Vista and later
%EQUATE `STI_VERSION_3 = &H00000003 OR %STI_VERSION_FLAG_UNICODE
'#endif //#if (_WIN32_WINNT >= 0x0600)
%EQUATE `STI_VERSION_MIN_ALLOWED = &H00000002
'#ifdef UNICODE
'#define STI_VERSION (STI_VERSION_REAL | STI_VERSION_FLAG_UNICODE)
'#else
'#define STI_VERSION (STI_VERSION_REAL)
'#endif
' //
' // Maximum length of internal device name
' //
%EQUATE `STI_MAX_INTERNAL_NAME_LENGTH = 128
' // begin sti_device_information
' //
' // Device information definitions and prototypes
' // ----------------------------------------------
' //
' //
' // Following information is used for enumerating still image devices , currently configured
' // in the system. Presence of the device in the enumerated list does not mean availability
' // of the device, it only means that device was installed at least once and had not been removed since.
' //
' //
' // Type of device ( scanner, camera) is represented by DWORD value with
' // hi word containing generic device type , and lo word containing sub-type
' //
' enum STI_DEVICE_MJ_TYPE {
%EQUATE `StiDeviceTypeDefault = 0
%EQUATE `StiDeviceTypeScanner = 1
'#if (_WIN32_WINNT >= 0x0501) // Windows XP and later
%EQUATE `StiDeviceTypeDigitalCamera = 2
%EQUATE `StiDeviceTypeStreamingVideo = 3
'#else
' StiDeviceTypeDigitalCamera = 2
'#endif //#if (_WIN32_WINNT >= 0x0501)
'typedef DWORD STI_DEVICE_TYPE;
' //
' // Macros to extract device type/subtype from single type field
' //
'#define GET_STIDEVICE_TYPE(dwDevType) HIWORD(dwDevType)
'#define GET_STIDEVICE_SUBTYPE(dwDevType) LOWORD(dwDevType)
MACRO GET_STIDEVICE_TYPE(dwDevType) = HI(WORD, dwDevType)
MACRO GET_STIDEVICE_SUBTYPE(dwDevType) = LO(WORD, dwDevType)
' //
' // Device capabilities bits.
' // Various capabilities are grouped into separate bitmasks
' //
' // Size = 4 bytes
TYPE STI_DEV_CAPS DWORD
 dwGeneric AS DWORD
END TYPE
' //
' // Generic capabilities mask contain 16 bits , common for all devices, maintained by MS
' // and 16 bits , which USD can use for proprietary capbailities reporting.
' //
'#define GET_STIDCOMMON_CAPS(dwGenericCaps) LOWORD(dwGenericCaps)
'#define GET_STIVENDOR_CAPS(dwGenericCaps) HIWORD(dwGenericCaps)
MACRO GET_STIDCOMMON_CAPS(dwGenericCaps) = LO(WORD, dwGenericCaps)
MACRO GET_STIVENDOR_CAPS(dwGenericCaps) = HI(WORD, dwGenericCaps)
'#define STI_GENCAP_COMMON_MASK (DWORD)0x00ff
%EQUATE `STI_GENCAP_COMMON_MASK = &H00ff
' //
' // Notifications are supported.
' // If this capability set , device can be subscribed to .
' //
%EQUATE `STI_GENCAP_NOTIFICATIONS = &H00000001
' //
' // Polling required .
' // This capability is used when previous is set to TRUE. Presence of it means
' // that device is not capable of issuing "truly" asyncronous notifications, but can
' // be polled to determine the moment when event happened
%EQUATE `STI_GENCAP_POLLING_NEEDED = &H00000002
' //
' // Generate event on device arrival
' // If this capability is set, still image service will generate event when device
' // instance is successfully initialized ( typically in response to PnP arrival)
' //
' // Note: on initial service enumeration events will nto be generated to avoid
' // end-user confusion.
' //
%EQUATE `STI_GENCAP_GENERATE_ARRIVALEVENT = &H00000004
' //
' // Auto port selection on non-PnP buses
' // This capability indicates that USD is able to detect non-PnP device on a
' // bus , device is supposed to be attached to.
' //
%EQUATE `STI_GENCAP_AUTO_PORTSELECT = &H00000008
'#if (_WIN32_WINNT >= 0x0501) // Windows XP and later
' //
' // WIA capability bit.
' // This capability indicates that USD is WIA capable.
' //
%EQUATE `STI_GENCAP_WIA = &H00000010
' //
' // Subset driver bit.
' // This capability indicates that there is more featured driver exists. All
' // of inbox driver has this bit set. Fully featured (IHV) driver shouldn't have
' // this bit set.
' //
%EQUATE `STI_GENCAP_SUBSET = &H00000020
'#endif //#if (_WIN32_WINNT >= 0x0501)
'#if (_WIN32_WINNT >= 0x0600) // Windows Vista and later
#IF %WINVER >= &H0600
%EQUATE `WIA_INCOMPAT_XP = &H00000001
#ENDIF
'#endif //#if (_WIN32_WINNT >= 0x0600)
' //
' //
' // Type of bus connection for those in need to know
' //
%EQUATE `STI_HW_CONFIG_UNKNOWN = &H0001
%EQUATE `STI_HW_CONFIG_SCSI = &H0002
%EQUATE `STI_HW_CONFIG_USB = &H0004
%EQUATE `STI_HW_CONFIG_SERIAL = &H0008
%EQUATE `STI_HW_CONFIG_PARALLEL = &H0010
' //
' // Device information structure, this is not configurable. This data is returned from
' // device enumeration API and is used for populating UI or selecting which device
' // should be used in current session
' //
' // Size = 292 bytes
TYPE STI_DEVICE_INFORMATIONW DWORD
 dwSize AS DWORD
 DeviceType AS DWORD ' STI_DEVICE_TYPE enum
 szDeviceInternalName AS WSTRINGZ * %STI_MAX_INTERNAL_NAME_LENGTH ' WCHAR
 DeviceCapabilities AS STI_DEV_CAPS ' STI_DEV_CAPS
 dwHardwareConfiguration AS DWORD
 pszVendorDescription AS WSTRINGZ PTR
 pszDeviceDescription AS WSTRINGZ PTR
 pszPortName AS WSTRINGZ PTR
 pszPropProvider AS WSTRINGZ PTR
 pszLocalName AS WSTRINGZ PTR
END TYPE
'typedef struct _STI_DEVICE_INFORMATIONA {
' DWORD dwSize;
' ' // Type of the hardware imaging device
' STI_DEVICE_TYPE DeviceType;
' ' // Device identifier for reference when creating device object
' CHAR szDeviceInternalName[STI_MAX_INTERNAL_NAME_LENGTH];
' ' // Set of capabilities flags
' STI_DEV_CAPS DeviceCapabilities;
' ' // This includes bus type
' DWORD dwHardwareConfiguration;
' ' // Vendor description string
' LPCSTR pszVendorDescription;
' ' // Device description , provided by vendor
' LPCSTR pszDeviceDescription;
' ' // String , representing port on which device is accessible.
' LPCSTR pszPortName;
' ' // Control panel propery provider
' LPCSTR pszPropProvider;
' ' // Local specific ("friendly") name of the device, mainly used for showing in the UI
' LPCSTR pszLocalName;
'} STI_DEVICE_INFORMATIONA, *PSTI_DEVICE_INFORMATIONA;
' // Size = 164 bytes
'TYPE STI_DEVICE_INFORMATIONA DWORD
' dwSize AS DWORD
' DeviceType AS DWORD ' STI_DEVICE_TYPE enum
' szDeviceInternalName AS ASCIIZ * %STI_MAX_INTERNAL_NAME_LENGTH ' CHAR
' DeviceCapabilities AS STI_DEV_CAPS ' STI_DEV_CAPS
' dwHardwareConfiguration AS DWORD
' pszVendorDescription AS ASCIIZ PTR
' pszDeviceDescription AS ASCIIZ PTR
' pszPortName AS ASCIIZ PTR
' pszPropProvider AS ASCIIZ PTR
' pszLocalName AS ASCIIZ PTR
'END TYPE
'MACRO STI_DEVICE_INFORMATION = STI_DEVICE_INFORMATIONA
MACRO STI_DEVICE_INFORMATION = STI_DEVICE_INFORMATIONW
' //
' // EXTENDED STI INFORMATION TO COVER WIA
' //
'typedef struct _STI_WIA_DEVICE_INFORMATIONW {
' DWORD dwSize;
' ' // Type of the hardware imaging device
' STI_DEVICE_TYPE DeviceType;
' ' // Device identifier for reference when creating device object
' WCHAR szDeviceInternalName[STI_MAX_INTERNAL_NAME_LENGTH];
' ' // Set of capabilities flags
' STI_DEV_CAPS DeviceCapabilities;
' ' // This includes bus type
' DWORD dwHardwareConfiguration;
' ' // Vendor description string
' LPWSTR pszVendorDescription;
' ' // Device description , provided by vendor
' LPWSTR pszDeviceDescription;
' ' // String , representing port on which device is accessible.
' LPWSTR pszPortName;
' ' // Control panel propery provider
' LPWSTR pszPropProvider;
' ' // Local specific ("friendly") name of the device, mainly used for showing in the UI
' LPWSTR pszLocalName;
' ' //
' ' // WIA values
' ' //
' LPWSTR pszUiDll;
' LPWSTR pszServer;
'} STI_WIA_DEVICE_INFORMATIONW, *PSTI_WIA_DEVICE_INFORMATIONW;
' // Size = 300 bytes
TYPE STI_WIA_DEVICE_INFORMATIONW DWORD
 dwSize AS DWORD
 DeviceType AS DWORD ' STI_DEVICE_TYPE
 szDeviceInternalName AS WSTRINGZ * %STI_MAX_INTERNAL_NAME_LENGTH ' WCHAR
 DeviceCapabilities AS STI_DEV_CAPS ' STI_DEV_CAPS
 dwHardwareConfiguration AS DWORD
 pszVendorDescription AS WSTRINGZ PTR
 pszDeviceDescription AS WSTRINGZ PTR
 pszPortName AS WSTRINGZ PTR
 pszPropProvider AS WSTRINGZ PTR
 pszLocalName AS WSTRINGZ PTR
 pszUiDll AS WSTRINGZ PTR
 pszServer AS WSTRINGZ PTR
END TYPE
'typedef struct _STI_WIA_DEVICE_INFORMATIONA {
' DWORD dwSize;
' ' // Type of the hardware imaging device
' STI_DEVICE_TYPE DeviceType;
' ' // Device identifier for reference when creating device object
' CHAR szDeviceInternalName[STI_MAX_INTERNAL_NAME_LENGTH];
' ' // Set of capabilities flags
' STI_DEV_CAPS DeviceCapabilities;
' ' // This includes bus type
' DWORD dwHardwareConfiguration;
' ' // Vendor description string
' LPCSTR pszVendorDescription;
' ' // Device description , provided by vendor
' LPCSTR pszDeviceDescription;
' ' // String , representing port on which device is accessible.
' LPCSTR pszPortName;
' ' // Control panel propery provider
' LPCSTR pszPropProvider;
' ' // Local specific ("friendly") name of the device, mainly used for showing in the UI
' LPCSTR pszLocalName;
' ' //
' ' // WIA values
' ' //
' LPCSTR pszUiDll;
' LPCSTR pszServer;
'} STI_WIA_DEVICE_INFORMATIONA, *PSTI_WIA_DEVICE_INFORMATIONA;
' // Size = 172 bytes
'TYPE STI_WIA_DEVICE_INFORMATIONA DWORD
' dwSize AS DWORD
' DeviceType AS DWORD ' STI_DEVICE_TYPE
' szDeviceInternalName AS ASCIIZ * %STI_MAX_INTERNAL_NAME_LENGTH ' CHAR
' DeviceCapabilities AS STI_DEV_CAPS ' STI_DEV_CAPS
' dwHardwareConfiguration AS DWORD
' pszVendorDescription AS ASCIIZ PTR
' pszDeviceDescription AS ASCIIZ PTR
' pszPortName AS ASCIIZ PTR
' pszPropProvider AS ASCIIZ PTR
' pszLocalName AS ASCIIZ PTR
' pszUiDll AS ASCIIZ PTR
' pszServer AS ASCIIZ PTR
'END TYPE
'MACRO STI_WIA_DEVICE_INFORMATION = STI_WIA_DEVICE_INFORMATIONA
MACRO STI_WIA_DEVICE_INFORMATION = STI_WIA_DEVICE_INFORMATIONW
' // end sti_device_information
' //
' // Device state information.
' // ------------------------
' //
' // Following types are used to inquire state characteristics of the device after
' // it had been opened.
' //
' // Device configuration structure contains configurable parameters reflecting
' // current state of the device
' //
' //
' // Device hardware status.
' //
' //
' // Individual bits for state acquiring through StatusMask
' //
' // State of hardware as known to USD
%EQUATE `STI_DEVSTATUS_ONLINE_STATE = &H0001
' // State of pending events ( as known to USD)
%EQUATE `STI_DEVSTATUS_EVENTS_STATE = &H0002
' //
' // Online state values
' //
%EQUATE `STI_ONLINESTATE_OPERATIONAL = &H00000001
%EQUATE `STI_ONLINESTATE_PENDING = &H00000002
%EQUATE `STI_ONLINESTATE_ERROR = &H00000004
%EQUATE `STI_ONLINESTATE_PAUSED = &H00000008
%EQUATE `STI_ONLINESTATE_PAPER_JAM = &H00000010
%EQUATE `STI_ONLINESTATE_PAPER_PROBLEM = &H00000020
%EQUATE `STI_ONLINESTATE_OFFLINE = &H00000040
%EQUATE `STI_ONLINESTATE_IO_ACTIVE = &H00000080
%EQUATE `STI_ONLINESTATE_BUSY = &H00000100
%EQUATE `STI_ONLINESTATE_TRANSFERRING = &H00000200
%EQUATE `STI_ONLINESTATE_INITIALIZING = &H00000400
%EQUATE `STI_ONLINESTATE_WARMING_UP = &H00000800
%EQUATE `STI_ONLINESTATE_USER_INTERVENTION = &H00001000
%EQUATE `STI_ONLINESTATE_POWER_SAVE = &H00002000
' //
' // Event processing parameters
' //
%EQUATE `STI_EVENTHANDLING_ENABLED = &H00000001
%EQUATE `STI_EVENTHANDLING_POLLING = &H00000002
%EQUATE `STI_EVENTHANDLING_PENDING = &H00000004
'typedef struct _STI_DEVICE_STATUS {
' DWORD dwSize;
' ' // Request field - bits of status to verify
' DWORD StatusMask;
' ' //
' ' // Fields are set when status mask contains STI_DEVSTATUS_ONLINE_STATE bit set
' ' //
' ' // Bitmask describing device state
' DWORD dwOnlineState;
' ' // Device status code as defined by vendor
' DWORD dwHardwareStatusCode;
' ' //
' ' // Fields are set when status mask contains STI_DEVSTATUS_EVENTS_STATE bit set
' ' //
' ' // State of device notification processing (enabled, pending)
' DWORD dwEventHandlingState;
' ' // If device is polled, polling interval in ms
' DWORD dwPollingInterval;
'} STI_DEVICE_STATUS,*PSTI_DEVICE_STATUS;
' // Size = 24 bytes
TYPE STI_DEVICE_STATUS DWORD
 dwSize AS DWORD
 StatusMask AS DWORD
 dwOnlineState AS DWORD
 dwHardwareStatusCode AS DWORD
 dwEventHandlingState AS DWORD
 dwPollingInterval AS DWORD
END TYPE
' //
' // Structure to describe diagnostic ( test ) request to be processed by USD
' //
' // Basic test for presence of associated hardware
%EQUATE `STI_DIAGCODE_HWPRESENCE = &H00000001
' //
' // Status bits for diagnostic
' //
' //
' // generic diagnostic errors
' //
' // Size = 524 bytes
TYPE STI_ERROR_INFOW DWORD
 dwSize AS DWORD
 dwGenericError AS DWORD
 dwVendorError AS DWORD
 szExtendedErrorText AS WSTRINGZ * 255 ' WCHAR
END TYPE
'typedef struct _ERROR_INFOA {
' DWORD dwSize;
' DWORD dwGenericError;
' DWORD dwVendorError;
' CHAR szExtendedErrorText[255];
'} STI_ERROR_INFOA,*PSTI_ERROR_INFOA;
' // Size = 268 bytes
'TYPE STI_ERROR_INFOA DWORD
' dwSize AS DWORD
' dwGenericError AS DWORD
' dwVendorError AS DWORD
' szExtendedErrorText AS ASCIIZ * 255 ' CHAR
'END TYPE
'MACRO STI_ERROR_INFO = STI_ERROR_INFOA
MACRO STI_ERROR_INFO = STI_ERROR_INFOW
'typedef struct _STI_DIAG {
' DWORD dwSize;
' ' // Diagnostic request fields. Are set on request by caller
' ' // One of the
' DWORD dwBasicDiagCode;
' DWORD dwVendorDiagCode;
' ' // Response fields
' DWORD dwStatusMask;
' STI_ERROR_INFO sErrorInfo;
'} STI_DIAG,*LPSTI_DIAG;
' //
'typedef STI_DIAG DIAG;
'typedef LPSTI_DIAG LPDIAG;
' // Size = 540 bytes
TYPE STI_DIAG DWORD
 dwSize AS DWORD
 dwBasicDiagCode AS DWORD
 dwVendorDiagCode AS DWORD
 dwStatusMask AS DWORD
 sErrorInfo AS STI_ERROR_INFO ' STI_ERROR_INFO
END TYPE
' // end device state information.
' //
' // Flags passed to WriteToErrorLog call in a first parameter, indicating type of the message
' // which needs to be logged
' //
%EQUATE `STI_TRACE_INFORMATION = &H00000001
%EQUATE `STI_TRACE_WARNING = &H00000002
%EQUATE `STI_TRACE_ERROR = &H00000004
' //
' // Event notification mechansims.
' // ------------------------------
' //
' // Those are used to inform last subscribed caller of the changes in device state, initiated by
' // device.
' //
' // The only supported discipline of notification is stack. The last caller to subscribe will be notified
' // and will receive notification data. After caller unsubscribes , the previously subscribed caller will
' // become active.
' //
' // Notifications are sent to subscriber via window message. Window handle is passed as
' // parameter
%EQUATE `STI_SUBSCRIBE_FLAG_WINDOW = &H0001
' // Device notification is signalling Win32 event ( auto-set event). Event handle
' // is passed as a parameter
%EQUATE `STI_SUBSCRIBE_FLAG_EVENT = &H0002
'typedef struct _STISUBSCRIBE {
' DWORD dwSize;
' DWORD dwFlags;
' ' // Not used . Will be used for subscriber to set bit mask filtering different events
' DWORD dwFilter;
' ' // When STI_SUBSCRIBE_FLAG_WINDOW bit is set, following fields should be set
' ' // Handle of the window which will receive notification message
' HWND hWndNotify;
' ' // Handle of Win32 auto-reset event , which will be signalled whenever device has
' ' // notification pending
' HANDLE hEvent;
' ' // Code of notification message, sent to window
' UINT uiNotificationMessage;
'} STISUBSCRIBE,*LPSTISUBSCRIBE;
' // Size = 24 bytes
TYPE STISUBSCRIBE DWORD
 dwSize AS DWORD
 dwFlags AS DWORD
 dwFilter AS DWORD
 hWndNotify AS DWORD
 hEvent AS DWORD
 uiNotificationMessage AS DWORD ' UINT
END TYPE
%EQUATE `MAX_NOTIFICATION_DATA = 64
' //
' // Structure to describe notification information
' //
'typedef struct _STINOTIFY {
' DWORD dwSize; ' // Total size of the notification structure
' ' // GUID of the notification being retrieved
' GUID guidNotificationCode;
' ' // Vendor specific notification description
' BYTE abNotificationData[MAX_NOTIFICATION_DATA]; ' // USD specific
'} STINOTIFY,*LPSTINOTIFY;
' // Size = 84 bytes
TYPE STINOTIFY DWORD
 dwSize AS DWORD ' // Total size of the notification structure
 guidNotificationCode AS GUID
 abNotificationData(%MAX_NOTIFICATION_DATA - 1) AS BYTE ' // USD specific
END TYPE
' // end event_mechanisms
' //
' // STI device broadcasting
' //
' //
' // When STI Device is being added or removed, PnP broadacst is being sent , but it is not obvious
' // for application code to recognize if it is STI device and if so, what is the name of the
' // device. STI subsystem will analyze PnP broadcasts and rebroadcast another message via
' // BroadcastSystemMessage / WM_DEVICECHANGE / DBT_USERDEFINED .
' // String passed as user defined message contains STI prefix, action and device name
'#define STI_ADD_DEVICE_BROADCAST_ACTION "Arrival"
'#define STI_REMOVE_DEVICE_BROADCAST_ACTION "Removal"
$STI_ADD_DEVICE_BROADCAST_ACTION = "Arrival"
$STI_REMOVE_DEVICE_BROADCAST_ACTION = "Removal"
'#define STI_ADD_DEVICE_BROADCAST_STRING "STI\\" STI_ADD_DEVICE_BROADCAST_ACTION "\\%s"
'#define STI_REMOVE_DEVICE_BROADCAST_STRING "STI\\" STI_REMOVE_DEVICE_BROADCAST_ACTION "\\%s"
$STI_ADD_DEVICE_BROADCAST_STRING = "STI\Arrival\%s"
$STI_REMOVE_DEVICE_BROADCAST_STRING = "STI\Removal\%s"
' // end STI broadcasting
' //
' // Device create modes
' //
' // Device is being opened only for status querying and notifications receiving
%EQUATE `STI_DEVICE_CREATE_STATUS = &H00000001
' // Device is being opened for data transfer ( supersedes status mode)
%EQUATE `STI_DEVICE_CREATE_DATA = &H00000002
%EQUATE `STI_DEVICE_CREATE_BOTH = &H00000003
' //
' // Bit mask for legitimate mode bits, which can be used when calling CreateDevice
' //
%EQUATE `STI_DEVICE_CREATE_MASK = &H0000FFFF
' //
' // Flags controlling device enumeration
' //
%EQUATE `STIEDFL_ALLDEVICES = &H00000000
%EQUATE `STIEDFL_ATTACHEDONLY = &H00000001
' //
' // Control code , sent to the device through raw control interface
' //
'typedef DWORD STI_RAW_CONTROL_CODE;
' //
' // All raw codes below this one are reserved for future use.
' //
%EQUATE `STI_RAW_RESERVED = &H1000
' /*
' * COM Interfaces to STI
' */
'STDMETHODIMP StiCreateInstanceW(HINSTANCE hinst, DWORD dwVer, interface IStillImageW **ppSti, LPUNKNOWN punkOuter);
'#if defined(UNICODE) || defined(STI_UNICODE)
'#define IID_IStillImage IID_IStillImageW
'#define IStillImage IStillImageW
'#define StiCreateInstance StiCreateInstanceW
'#endif
DECLARE FUNCTION StiCreateInstanceW LIB "sti.dll" ALIAS "StiCreateInstanceW" ( BYVAL hinst AS QUAD , BYVAL dwVer AS QUAD , BYREF ppSti AS IStillImageW , BYVAL punkOuter AS IUnknown ) AS LONG
DECLARE FUNCTION StiCreateInstance LIB "sti.dll" ALIAS "StiCreateInstanceW" ( BYVAL hinst AS QUAD
 , BYVAL dwVer AS DWORD
 , BYREF ppSti AS IStillImage
 , BYVAL punkOuter AS IUnknown
 ) AS LONG
'/*
' * IStillImage interface
' *
' * Top level STI access interface.
' *
' */
' ########################################################################################
' Interface name = IStillImageW
' IID = 641BD880-2DC8-11D0-90EA-00AA0060F86C
' Inherited interface = IUnknown
' ########################################################################################
INTERFACE IStillImageW $IID_IStillImageW
 INHERIT IUnknown
 ' =====================================================================================
 METHOD Initialize ( ' VTable offset = 12
 BYVAL hinst AS DWORD
 , BYVAL dwVersion AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetDeviceList ( ' VTable offset = 16
 BYVAL dwType AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYREF pdwItemsReturned AS DWORD
 , BYREF ppBuffer AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetDeviceInfo ( ' VTable offset = 20
 BYREF pwszDeviceName AS WSTRINGZ
 , BYREF ppBuffer AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD CreateDevice ( ' VTable offset = 24
 BYVAL pwszDeviceName AS DWORD
 , BYVAL dwMode AS DWORD
 , BYREF pDevice AS IStiDevice
 , BYVAL punkOuter AS IUnknown
 ) AS LONG
 ' =====================================================================================
 METHOD GetDeviceValue ( ' VTable offset = 28
 BYREF pwszDeviceName AS WSTRINGZ
 , BYREF pValueName AS WSTRINGZ
 , BYREF pType AS DWORD
 , BYVAL pData AS DWORD
 , BYREF cbData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetDeviceValue ( ' VTable offset = 32
 BYREF pwszDeviceName AS WSTRINGZ
 , BYREF pValueName AS WSTRINGZ
 , BYVAL Type AS DWORD
 , BYVAL pData AS DWORD
 , BYVAL cbData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetSTILaunchInformation ( ' VTable offset = 36
 BYREF pwszDeviceName AS WSTRINGZ
 , BYREF pdwEventCode AS DWORD
 , BYREF pwszEventName AS WSTRINGZ
 ) AS LONG
 ' =====================================================================================
 METHOD RegisterLaunchApplication ( ' VTable offset = 40
 BYREF pwszAppName AS WSTRINGZ
 , BYREF pwszCommandLine AS WSTRINGZ
 ) AS LONG
 ' =====================================================================================
 METHOD UnregisterLaunchApplication ( ' VTable offset = 44
 BYREF pwszAppName AS WSTRINGZ
 ) AS LONG
 ' =====================================================================================
 METHOD EnableHwNotifications ( ' VTable offset = 48
 BYREF pwszDeviceName AS WSTRINGZ
 , BYVAL bNewState AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetHwNotificationState ( ' VTable offset = 52
 BYREF pwszDeviceName AS WSTRINGZ
 , BYREF pbCurrentState AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD RefreshDeviceBus ( ' VTable offset = 56
 BYREF pwszDeviceName AS WSTRINGZ
 ) AS LONG
 ' =====================================================================================
 METHOD LaunchApplicationForDevice ( ' VTable offset = 60
 BYREF pwszDeviceName AS WSTRINGZ
 , BYREF pwszAppName AS WSTRINGZ
 , BYREF pStiNotify AS STINOTIFY
 ) AS LONG
 ' =====================================================================================
 METHOD SetupDeviceParameters ( ' VTable offset = 64
 BYREF pDevInfo AS STI_DEVICE_INFORMATION
 ) AS LONG
 ' =====================================================================================
 METHOD WriteToErrorLog ( ' VTable offset = 68
 BYVAL dwMessageType AS DWORD
 , BYREF pszMessage AS WSTRINGZ
 ) AS LONG
 ' =====================================================================================
END INTERFACE
' ########################################################################################
' Interface name = IStillImageA
' IID = A7B1F740-1D7F-11D1-ACA9-00A02438AD48
' Inherited interface = IUnknown
' ########################################################################################
INTERFACE IStillImage $IID_IStillImage
 INHERIT IUnknown
 ' =====================================================================================
 METHOD Initialize ( ' VTable offset = 12
 BYVAL hinst AS DWORD
 , BYVAL dwVersion AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetDeviceList ( ' VTable offset = 16
 BYVAL dwType AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYREF pdwItemsReturned AS DWORD
 , BYREF ppBuffer AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetDeviceInfo ( ' VTable offset = 20
 BYREF pwszDeviceName AS ASCIIZ
 , BYREF ppBuffer AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD CreateDevice ( ' VTable offset = 24
 BYREF pwszDeviceName AS ASCIIZ
 , BYVAL dwMode AS DWORD
 , BYREF pDevice AS IStiDevice
 , BYVAL punkOuter AS IUnknown
 ) AS LONG
 ' =====================================================================================
 METHOD GetDeviceValue ( ' VTable offset = 28
 BYREF pwszDeviceName AS ASCIIZ
 , BYREF pValueName AS ASCIIZ
 , BYREF pType AS DWORD
 , BYVAL pData AS DWORD
 , BYREF cbData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetDeviceValue ( ' VTable offset = 32
 BYREF pwszDeviceName AS ASCIIZ
 , BYREF pValueName AS ASCIIZ
 , BYVAL Type AS DWORD
 , BYVAL pData AS DWORD
 , BYVAL cbData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetSTILaunchInformation ( ' VTable offset = 36
 BYREF pwszDeviceName AS ASCIIZ
 , BYREF pdwEventCode AS DWORD
 , BYREF pwszEventName AS ASCIIZ
 ) AS LONG
 ' =====================================================================================
 METHOD RegisterLaunchApplication ( ' VTable offset = 40
 BYREF pwszAppName AS ASCIIZ
 , BYREF pwszCommandLine AS ASCIIZ
 ) AS LONG
 ' =====================================================================================
 METHOD UnregisterLaunchApplication ( ' VTable offset = 44
 BYREF pwszAppName AS ASCIIZ
 ) AS LONG
 ' =====================================================================================
 METHOD EnableHwNotifications ( ' VTable offset = 48
 BYREF pwszDeviceName AS ASCIIZ
 , BYVAL bNewState AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetHwNotificationState ( ' VTable offset = 52
 BYREF pwszDeviceName AS ASCIIZ
 , BYREF pbCurrentState AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD RefreshDeviceBus ( ' VTable offset = 56
 BYREF pwszDeviceName AS ASCIIZ
 ) AS LONG
 ' =====================================================================================
 METHOD LaunchApplicationForDevice ( ' VTable offset = 60
 BYREF pwszDeviceName AS ASCIIZ
 , BYREF pwszAppName AS ASCIIZ
 , BYREF pStiNotify AS STINOTIFY
 ) AS LONG
 ' =====================================================================================
 METHOD SetupDeviceParameters ( ' VTable offset = 64
 BYREF pDevInfo AS STI_DEVICE_INFORMATION
 ) AS LONG
 ' =====================================================================================
 METHOD WriteToErrorLog ( ' VTable offset = 68
 BYVAL dwMessageType AS DWORD
 , BYREF pszMessage AS ASCIIZ
 ) AS LONG
 ' =====================================================================================
END INTERFACE
'/*
' * IStillImage_Device interface
' *
' * This is generic per device interface. Specialized interfaces are also
' * available
' */
' ########################################################################################
' Interface name = IStiDevice
' IID = 6CFA5A80-2DC8-11D0-90EA-00AA0060F86C
' Inherited interface = IUnknown
' ########################################################################################
INTERFACE IStiDevice $IID_IStiDevice
 INHERIT IUnknown
 ' =====================================================================================
 METHOD Initialize ( ' VTable offset = 12
 BYVAL hinst AS DWORD
 , BYREF pwszDeviceName AS WSTRINGZ
 , BYVAL dwVersion AS DWORD
 , BYVAL dwMode AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetCapabilities ( ' VTable offset = 16
 BYREF pDevCaps AS STI_DEV_CAPS
 ) AS LONG
 ' =====================================================================================
 METHOD GetStatus ( ' VTable offset = 20
 BYREF pDevStatus AS STI_DEVICE_STATUS
 ) AS LONG
 ' =====================================================================================
 METHOD DeviceReset ( ' VTable offset = 24
 ) AS LONG
 ' =====================================================================================
 METHOD Diagnostic ( ' VTable offset = 28
 BYREF pBuffer AS STI_DIAG
 ) AS LONG
 ' =====================================================================================
 METHOD Escape ( ' VTable offset = 32
 BYVAL EscapeFunction AS DWORD
 , BYVAL lpInData AS DWORD
 , BYVAL cbInDataSize AS DWORD
 , BYVAL pOutData AS DWORD
 , BYVAL dwOutDataSize AS DWORD
 , BYREF pdwActualData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetLastError ( ' VTable offset = 36
 BYREF pdwLastDeviceError AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD LockDevice ( ' VTable offset = 40
 BYVAL dwTimeOut AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UnLockDevice ( ' VTable offset = 44
 ) AS LONG
 ' =====================================================================================
 METHOD RawReadData ( ' VTable offset = 48
 BYVAL lpBuffer AS DWORD
 , BYREF lpdwNumberOfBytes AS DWORD
 , BYREF lpOverlapped AS OVERLAPPED
 ) AS LONG
 ' =====================================================================================
 METHOD RawWriteData ( ' VTable offset = 52
 BYVAL lpBuffer AS DWORD
 , BYVAL nNumberOfBytes AS DWORD
 , BYREF lpOverlapped AS OVERLAPPED
 ) AS LONG
 ' =====================================================================================
 METHOD RawReadCommand ( ' VTable offset = 56
 BYVAL lpBuffer AS DWORD
 , BYREF lpdwNumberOfBytes AS DWORD
 , BYREF lpOverlapped AS OVERLAPPED
 ) AS LONG
 ' =====================================================================================
 METHOD RawWriteCommand ( ' VTable offset = 60
 BYVAL lpBuffer AS DWORD
 , BYVAL nNumberOfBytes AS DWORD
 , BYREF lpOverlapped AS OVERLAPPED
 ) AS LONG
 ' =====================================================================================
 METHOD Subscribe ( ' VTable offset = 64
 ) AS LONG
 ' =====================================================================================
 METHOD GetLastNotificationData ( ' VTable offset = 68
 BYREF lpNotify AS STINOTIFY
 ) AS LONG
 ' =====================================================================================
 METHOD UnSubscribe ( ' VTable offset = 72
 ) AS LONG
 ' =====================================================================================
 METHOD GetLastErrorInfo ( ' VTable offset = 76
 BYREF pLastErrorInfo AS STI_ERROR_INFO
 ) AS LONG
 ' =====================================================================================
END INTERFACE
' //
' // Reset packing
' //
'#include <poppack.h>
#ENDIF
