Metropoli BBS
VIEWER: os2mm.pas MODE: TEXT (CP437)
{█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█}
{█                                                       █}
{█      Virtual Pascal Runtime Library.  Version 1.1.    █}
{█      OS/2 MultiMedia API interface                    █}
{█      ─────────────────────────────────────────────────█}
{█      Copyright (C) 1996 fPrint UK Ltd                 █}
{█                                                       █}
{▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀}

Unit Os2MM;

{$Cdecl+,AlignRec-,OrgName+,T-,Delphi+}

{$L OS2.LIB}

interface

uses Use32, Os2Def, Os2PmApi;

{----[ OS2MEDEF ]----}

type
  pVoid = Pointer;
  Short = SmallWord;

  Handle  = hwnd;

  mmTime  = Cardinal;
  pmmTime = ^mmTime;

  hmmIO   = uLong;
  phmmIO  = ^hmmIO;

  // spcbKey - Stream protocol Key
  spcbKey = record
    ulDataType    : uLong;
    ulDataSubType : uLong;
    ulIntKey      : uLong;              // Generated internal key
  end;
  pspcbKey = ^spcbKey;

  // MMTRACKINFO - This structure is used to represent a video, audio or
  // some other type of track within a digital video movie file.
  MMTrackInfo = record
    ulTrackID     : uLong;              // track identifier
    ulMediaType   : uLong;              // media type
    ulCountry     : uLong;              // country code for the track
    ulCodePage    : uLong;              // country code page for the track
    ulReserved1   : uLong;              // reserved must be 0
    ulReserved2   : uLong;              // reserved must be 0
  end;
  pMMTrackInfo = ^MMTrackInfo;

const
  // Bits Per Sample
  BPS_4     =  4;
  BPS_8     =  8;
  BPS_16    = 16;

  // Clipboard formats
  CF_RMID   = 10;
  CF_RIFF   = 11;
  CF_WAVE   = 12;
  CF_AVI    = 13;

  // Channels
  CH_1      = 1;          // Mono
  CH_2      = 2;          // Stereo
  CH_4      = 4;          // Quad

  // Sampling Rates
  HZ_8000   =  8000;
  HZ_11025  = 11025;
  HZ_14700  = 14700;      // SPV/2
  HZ_18900  = 18900;      // CD/XA Lvl C
  HZ_22050  = 22050;
  HZ_37800  = 37800;      // CD/XA Lvl B
  HZ_44100  = 44100;

  // Resource Formats
  RT_RMID   = 100;
  RT_RIFF   = 101;
  RT_WAVE   = 102;
  RT_AVI    = 103;
  RT_AVS    = 104;

const
  // Multimedia Datatypes (spcbKey values)
  DATATYPE_NULL           = $0000;
  SUBTYPE_NONE            = $0000;

  // WaveForm datatype
  DATATYPE_WAVEFORM       = $0001;
  // SubTypes for WaveForm
  WAVE_FORMAT_1M08        = $0001;
  WAVE_FORMAT_1S08        = $0002;
  WAVE_FORMAT_1M16        = $0003;
  WAVE_FORMAT_1S16        = $0004;
  WAVE_FORMAT_2M08        = $0005;
  WAVE_FORMAT_2S08        = $0006;
  WAVE_FORMAT_2M16        = $0007;
  WAVE_FORMAT_2S16        = $0008;
  WAVE_FORMAT_4M08        = $0009;
  WAVE_FORMAT_4S08        = $000a;
  WAVE_FORMAT_4M16        = $000b;
  WAVE_FORMAT_4S16        = $000c;
  WAVE_FORMAT_8M08        = $000d;
  WAVE_FORMAT_8S08        = $000e;
  WAVE_FORMAT_8M16        = $000f;
  WAVE_FORMAT_8S16        = $0010;

  // DigVideo datatypes
  DATATYPE_DIGVIDEO       = $0002;
  // Subtypes
  DIGVIDEO_PHOTOM         = $544F4850;  // Photmotion video, FOURCC value for phio
  DIGVIDEO_ULTIM          = $49544c55;  // Ultimotion video, FOURCC value for ulio
  DIGVIDEO_AVI            = $20495641;  // AVI video, FOURCC value for avio
  DIGVIDEO_MONITOR        = $206E6F6D;  // MONITOR video, FOURCC value for monitoring
  DIGVIDEO_FLC            = $63696C66;  // FLIC video, FOURCC value for flic
  DIGVIDEO_MPEG           = $4745504D;  // MPEG video, FOURCC value for MPEG

  // MuLaw datatypes
  DATATYPE_MULAW          = $0101;
  DATATYPE_RIFF_MULAW     = $0007;
  // SubTypes
  MULAW_8B8KS             = $0001;      // 8bit 8kHz stereo
  MULAW_8B11KS            = $0002;      // 8bit 11kHz stereo
  MULAW_8B22KS            = $0003;      // 8bit 22kHz stereo
  MULAW_8B44KS            = $0004;      // 8bit 44kHz stereo
  MULAW_8B8KM             = $0005;      // 8bit 8kHz mono
  MULAW_8B11KM            = $0006;      // 8bit 11kHz mono
  MULAW_8B22KM            = $0007;      // 8bit 22kHz mono
  MULAW_8B44KM            = $0008;      // 8bit 44kHz mono

  // ALaw datatypes
  DATATYPE_ALAW           = $0102;
  DATATYPE_RIFF_ALAW      = $0006;
  // Subtypes
  ALAW_8B8KS              = $0001;      // 8bit 8kHz stereo
  ALAW_8B11KS             = $0002;      // 8bit 11kHz stereo
  ALAW_8B22KS             = $0003;      // 8bit 22kHz stereo
  ALAW_8B44KS             = $0004;      // 8bit 44kHz stereo
  ALAW_8B8KM              = $0005;      // 8bit 8kHz mono
  ALAW_8B11KM             = $0006;      // 8bit 11kHz mono
  ALAW_8B22KM             = $0007;      // 8bit 22kHz mono
  ALAW_8B44KM             = $0008;      // 8bit 44kHz mono

  // ADPCM datatypes
  DATATYPE_ADPCM_AVC      = $0103;
  // Subtypes
  ADPCM_AVC_VOICE         = $0001;
  ADPCM_AVC_MUSIC         = $0002;
  ADPCM_AVC_STEREO        = $0003;
  ADPCM_AVC_HQ            = $0004;


  // CT_ADPCM datatypes
  DATATYPE_CT_ADPCM       = $0200;      // Creative Technologies
  // Subtypes
  CT_ADPCM_16B8KS         = $0001;      // 16bit 8kHz stereo
  CT_ADPCM_16B11KS        = $0002;      // 16bit 11kHz stereo
  CT_ADPCM_16B22KS        = $0003;      // 16bit 22kHz stereo
  CT_ADPCM_16B44KS        = $0004;      // 16bit 44kHz stereo
  CT_ADPCM_16B8KM         = $0005;      // 16bit 8kHz mono
  CT_ADPCM_16B11KM        = $0006;      // 16bit 11kHz mono
  CT_ADPCM_16B22KM        = $0007;      // 16bit 22kHz mono
  CT_ADPCM_16B44KM        = $0008;      // 16bit 44kHz mono

  // MIDI datatype
  DATATYPE_MIDI           = $0201;

  // Generic datatype
  DATATYPE_GENERIC        = $0202;

  // Speech Viewer Datatypes
  DATATYPE_SPV2           = $0203;
  // SubTypes
  SPV2_BPCM               = $0001;
  SPV2_PCM                = $0002;
  SPV2_NONE               = $0003;


  // CD-XA datatypes
  DATATYPE_CDXA_VIDEO     = $0204;      // CD-XA Video datatype
  DATATYPE_CDXA_DATA      = $0205;      // CD-XA sub-band data datatype
  DATATYPE_CDXA_AUDIO     = $0206;      // CD-XA ADPCM Audio datatype
  DATATYPE_CDXA_AUDIO_HD  = $0207;      // CD-XA ADPCM Audio with Headers
  DATATYPE_CDXA_HEADERS   = $0208;      // CD-XA Headers and Subheaders
  // Subtypes
  CDXA_LEVELB             = $0000;      // LEVEL B Audio Stereo
  CDXA_LEVELC             = $0001;      // LEVEL C Audio Stereo
  CDXA_LEVELB_MONO        = $0002;      // LEVEL B Audio Mono
  CDXA_LEVELC_MONO        = $0003;      // LEVEL C Audio Mono

  // Digispeech datatype
  DATATYPE_DIGISPEECH     = $0208;
  // Subtyoes
  DIGISPEECH_NATIVE       = $0001;

  // MPE>G-1 Audio Datatypes
  DATATYPE_MPEG1AUDIO     = $0050;
  // Subtypes
  MPEG1_FORMAT_3M16       = $0001;      // 32.000kHz,  Mono  , 16-bit
  MPEG1_FORMAT_3S16       = $0002;      // 32.000kHz,  Stereo, 16-bit
  MPEG1_FORMAT_4M16       = $0003;      // 44.1/48kHz, Mono  , 16-bit
  MPEG1_FORMAT_4S16       = $0004;      // 44.1/48kHz, Stereo, 16-bit

  // Unknown datatype
  DATATYPE_UNKNOWN        = $FFFFFFFF;

{----[ MEERROR ]----}

const
  // MCI Device Manager Error Return Codes
  MCIERR_BASE                       = 5000;
  MCIERR_SUCCESS                    = 0;
  MCIERR_INVALID_DEVICE_ID          = (MCIERR_BASE +   1);
  MCIERR_NO_MASTER                  = (MCIERR_BASE +   2);
  MCIERR_UNRECOGNIZED_KEYWORD       = (MCIERR_BASE +   3);
  MCIERR_MASTER_CONFLICT            = (MCIERR_BASE +   4);
  MCIERR_UNRECOGNIZED_COMMAND       = (MCIERR_BASE +   5);
  MCIERR_HARDWARE                   = (MCIERR_BASE +   6);
  MCIERR_INVALID_DEVICE_NAME        = (MCIERR_BASE +   7);
  MCIERR_OUT_OF_MEMORY              = (MCIERR_BASE +   8);
  MCIERR_DEVICE_OPEN                = (MCIERR_BASE +   9);
  MCIERR_CANNOT_LOAD_DRIVER         = (MCIERR_BASE +  10);
  MCIERR_MISSING_COMMAND_STRING     = (MCIERR_BASE +  11);
  MCIERR_PARAM_OVERFLOW             = (MCIERR_BASE +  12);
  MCIERR_MISSING_STRING_ARGUMENT    = (MCIERR_BASE +  13);
  MCIERR_BAD_INTEGER                = (MCIERR_BASE +  14);
  MCIERR_PARSER_INTERNAL            = (MCIERR_BASE +  15);
  MCIERR_DRIVER_INTERNAL            = (MCIERR_BASE +  16);
  MCIERR_MISSING_PARAMETER          = (MCIERR_BASE +  17);
  MCIERR_UNSUPPORTED_FUNCTION       = (MCIERR_BASE +  18);
  MCIERR_FILE_NOT_FOUND             = (MCIERR_BASE +  19);
  MCIERR_DEVICE_NOT_READY           = (MCIERR_BASE +  20);
  MCIERR_INTERNAL                   = (MCIERR_BASE +  21);
  MCIERR_DRIVER                     = (MCIERR_BASE +  22);
  MCIERR_CANNOT_USE_ALL             = (MCIERR_BASE +  23);
  MCIERR_MULTIPLE                   = (MCIERR_BASE +  24);
  MCIERR_EXTENSION_NOT_FOUND        = (MCIERR_BASE +  25);
  MCIERR_OUTOFRANGE                 = (MCIERR_BASE +  26);
  MCIERR_CANNOT_ADD_ALIAS           = (MCIERR_BASE +  27);
  MCIERR_FLAGS_NOT_COMPATIBLE       = (MCIERR_BASE +  28);
  MCIERR_CANNOT_USE_NOUNLOAD        = (MCIERR_BASE +  29);
  MCIERR_FILE_NOT_SAVED             = (MCIERR_BASE +  30);
  MCIERR_DEVICE_TYPE_REQUIRED       = (MCIERR_BASE +  31);
  MCIERR_DEVICE_LOCKED              = (MCIERR_BASE +  32);
  MCIERR_DUPLICATE_ALIAS            = (MCIERR_BASE +  33);
  MCIERR_INSTANCE_INACTIVE          = (MCIERR_BASE +  34);
  MCIERR_COMMAND_TABLE              = (MCIERR_BASE +  35);
  MCIERR_INI_FILE_LOCKED            = (MCIERR_BASE +  37);
  MCIERR_NO_AUDIO_SUPPORT           = (MCIERR_BASE +  40);
  MCIERR_NOT_IN_PM_SESSION          = (MCIERR_BASE +  41);
  MCIERR_DUPLICATE_KEYWORD          = (MCIERR_BASE +  42);
  MCIERR_COMMAND_STRING_OVERFLOW    = (MCIERR_BASE +  43);
  MCIERR_DRIVER_PROC_NOT_FOUND      = (MCIERR_BASE +  44);
  MCIERR_INVALID_DEVICE_TYPE        = (MCIERR_BASE +  45);
  MCIERR_INVALID_DEVICE_ORDINAL     = (MCIERR_BASE +  46);
  MCIERR_HEADPHONES_NOT_SET         = (MCIERR_BASE +  47);
  MCIERR_SPEAKERS_NOT_SET           = (MCIERR_BASE +  48);
  MCIERR_SOUND_NOT_SET              = (MCIERR_BASE +  49);
  MCIERR_INVALID_BUFFER             = (MCIERR_BASE +  50);
  MCIERR_INVALID_MEDIA_TYPE         = (MCIERR_BASE +  51);
  MCIERR_INVALID_CONNECTOR_INDEX    = (MCIERR_BASE +  52);
  MCIERR_NO_CONNECTION              = (MCIERR_BASE +  53);
  MCIERR_INVALID_FLAG               = (MCIERR_BASE +  54);
  MCIERR_CANNOT_LOAD_DSP_MOD        = (MCIERR_BASE +  55);
  MCIERR_ALREADY_CONNECTED          = (MCIERR_BASE +  56);
  MCIERR_INVALID_CALLBACK_HANDLE    = (MCIERR_BASE +  57);
  MCIERR_DRIVER_NOT_FOUND           = (MCIERR_BASE +  58);
  MCIERR_DUPLICATE_DRIVER           = (MCIERR_BASE +  59);
  MCIERR_INI_FILE                   = (MCIERR_BASE +  60);
  MCIERR_INVALID_GROUP_ID           = (MCIERR_BASE +  61);
  MCIERR_ID_ALREADY_IN_GROUP        = (MCIERR_BASE +  62);
  MCIERR_MEDIA_CHANGED              = (MCIERR_BASE +  63);
  MCIERR_MISSING_FLAG               = (MCIERR_BASE +  64);
  MCIERR_UNSUPPORTED_FLAG           = (MCIERR_BASE +  65);
  MCIERR_DRIVER_NOT_LOADED          = (MCIERR_BASE +  66);
  MCIERR_INVALID_MODE               = (MCIERR_BASE +  67);
  MCIERR_INVALID_ITEM_FLAG          = (MCIERR_BASE +  68);
  MCIERR_INVALID_TIME_FORMAT_FLAG   = (MCIERR_BASE +  69);
  MCIERR_SPEED_FORMAT_FLAG          = (MCIERR_BASE +  70);
  MCIERR_INVALID_AUDIO_FLAG         = (MCIERR_BASE +  71);
  MCIERR_NODEFAULT_DEVICE           = (MCIERR_BASE +  72);
  MCIERR_DUPLICATE_EXTENSION        = (MCIERR_BASE +  73);
  MCIERR_FILE_ATTRIBUTE             = (MCIERR_BASE +  74);
  MCIERR_DUPLICATE_CUEPOINT         = (MCIERR_BASE +  75);
  MCIERR_INVALID_CUEPOINT           = (MCIERR_BASE +  76);
  MCIERR_CUEPOINT_LIMIT_REACHED     = (MCIERR_BASE +  77);
  MCIERR_MISSING_ITEM               = (MCIERR_BASE +  78);
  MCIERR_MISSING_TIME_FORMAT        = (MCIERR_BASE +  79);
  MCIERR_MISSING_SPEED_FORMAT       = (MCIERR_BASE +  80);
  MCIERR_INVALID_CONNECTOR_TYPE     = (MCIERR_BASE +  81);
  MCIERR_TARGET_DEVICE_FULL         = (MCIERR_BASE +  82);
  MCIERR_UNSUPPORTED_CONN_TYPE      = (MCIERR_BASE +  83);
  MCIERR_CANNOT_MODIFY_CONNECTOR    = (MCIERR_BASE +  84);
  MCIERR_RECORD_ABORTED             = (MCIERR_BASE +  85);
  MCIERR_GROUP_COMMAND              = (MCIERR_BASE +  86);
  MCIERR_DEVICE_NOT_FOUND           = (MCIERR_BASE +  87);
  MCIERR_RESOURCE_NOT_AVAILABLE     = (MCIERR_BASE +  88);
  MCIERR_INVALID_IO_PROC            = (MCIERR_BASE +  89);
  MCIERR_WAVE_OUTPUTSINUSE          = (MCIERR_BASE +  90);
  MCIERR_WAVE_SETOUTPUTINUSE        = (MCIERR_BASE +  91);
  MCIERR_WAVE_INPUTSINUSE           = (MCIERR_BASE +  92);
  MCIERR_WAVE_SETINPUTINUSE         = (MCIERR_BASE +  93);
  MCIERR_WAVE_OUTPUTUNSPECIFIED     = (MCIERR_BASE +  94);
  MCIERR_WAVE_INPUTUNSPECIFIED      = (MCIERR_BASE +  95);
  MCIERR_WAVE_OUTPUTSUNSUITABLE     = (MCIERR_BASE +  96);
  MCIERR_WAVE_SETOUTPUTUNSUITABLE   = (MCIERR_BASE +  97);
  MCIERR_WAVE_INPUTSUNSUITABLE      = (MCIERR_BASE +  98);
  MCIERR_WAVE_SETINPUTUNSUITABLE    = (MCIERR_BASE +  99);
  MCIERR_SEQ_DIV_INCOMPATIBLE       = (MCIERR_BASE + 100);
  MCIERR_SEQ_PORT_INUSE             = (MCIERR_BASE + 101);
  MCIERR_SEQ_PORT_NONEXISTENT       = (MCIERR_BASE + 102);
  MCIERR_SEQ_PORT_MAPNODEVICE       = (MCIERR_BASE + 103);
  MCIERR_SEQ_PORT_MISCERROR         = (MCIERR_BASE + 104);
  MCIERR_SEQ_TIMER                  = (MCIERR_BASE + 105);
  MCIERR_VDP_COMMANDCANCELLED       = (MCIERR_BASE + 106);
  MCIERR_VDP_COMMANDFAILURE         = (MCIERR_BASE + 107);
  MCIERR_VDP_NOTSPUNUP              = (MCIERR_BASE + 108);
  MCIERR_VDP_NOCHAPTER              = (MCIERR_BASE + 109);
  MCIERR_VDP_NOSIDE                 = (MCIERR_BASE + 110);
  MCIERR_VDP_NOSIZE                 = (MCIERR_BASE + 111);
  MCIERR_VDP_INVALID_TIMEFORMAT     = (MCIERR_BASE + 112);
  MCIERR_CLIPBOARD_ERROR            = (MCIERR_BASE + 114);
  MCIERR_CANNOT_CONVERT             = (MCIERR_BASE + 115);
  MCIERR_CANNOT_REDO                = (MCIERR_BASE + 116);
  MCIERR_CANNOT_UNDO                = (MCIERR_BASE + 117);
  MCIERR_CLIPBOARD_EMPTY            = (MCIERR_BASE + 118);
  MCIERR_INVALID_WORKPATH           = (MCIERR_BASE + 119);
  MCIERR_INDETERMINATE_LENGTH       = (MCIERR_BASE + 120);
  MCIERR_DUPLICATE_EA               = (MCIERR_BASE + 121);
  MCIERR_INVALID_CONNECTION         = (MCIERR_BASE + 122);
  MCIERR_CHANNEL_OFF                = (MCIERR_BASE + 123);
  MCIERR_CANNOT_CHANGE_CHANNEL      = (MCIERR_BASE + 124);
  MCIERR_FILE_IO                    = (MCIERR_BASE + 125);
  MCIERR_SYSTEM_FILE                = (MCIERR_BASE + 126);
  MCIERR_DISPLAY_RESOLUTION         = (MCIERR_BASE + 127);
  MCIERR_NO_ASYNC_PLAY_ACTIVE       = (MCIERR_BASE + 128);
  MCIERR_UNSUPP_FORMAT_TAG          = (MCIERR_BASE + 129);
  MCIERR_UNSUPP_SAMPLESPERSEC       = (MCIERR_BASE + 130);
  MCIERR_UNSUPP_BITSPERSAMPLE       = (MCIERR_BASE + 131);
  MCIERR_UNSUPP_CHANNELS            = (MCIERR_BASE + 132);
  MCIERR_UNSUPP_FORMAT_MODE         = (MCIERR_BASE + 133);
  MCIERR_NO_DEVICE_DRIVER           = (MCIERR_BASE + 134);
  MCIERR_CODEC_NOT_SUPPORTED        = (MCIERR_BASE + 135);
  MCIERR_TUNER_NO_HW                = (MCIERR_BASE + 136);
  MCIERR_TUNER_NO_AFC               = (MCIERR_BASE + 137);
  MCIERR_TUNER_AFC_ON               = (MCIERR_BASE + 138);
  MCIERR_TUNER_CHANNEL_SKIPPED      = (MCIERR_BASE + 139);
  MCIERR_TUNER_CHANNEL_TOO_LOW      = (MCIERR_BASE + 140);
  MCIERR_TUNER_CHANNEL_TOO_HIGH     = (MCIERR_BASE + 141);
  MCIERR_AUD_CHANNEL_OUTOFRANGE     = (MCIERR_BASE + 142);
  MCIERR_TUNER_INVALID_REGION       = (MCIERR_BASE + 143);
  MCIERR_SIGNAL_INVALID             = (MCIERR_BASE + 144);
  MCIERR_TUNER_MODE                 = (MCIERR_BASE + 145);
  MCIERR_TUNER_REGION_NOT_SET       = (MCIERR_BASE + 146);
  MCIERR_TUNER_CHANNEL_NOT_SET      = (MCIERR_BASE + 147);
  MCIERR_CUSTOM_DRIVER_BASE         = (MCIERR_BASE + 256);

  // Sync/Stream Manager Error Return codes
  MEBASE                            = (MCIERR_BASE + 500);
  ERROR_INVALID_STREAM              = (MEBASE +   1);
  ERROR_INVALID_hID                 = (MEBASE +   2);
  ERROR_INVALID_OBJTYPE             = (MEBASE +   4);
  ERROR_INVALID_FLAG                = (MEBASE +   5);
  ERROR_INVALID_EVCB                = (MEBASE +   6);
  ERROR_INVALID_EVENT               = (MEBASE +   7);
  ERROR_INVALID_MMTIME              = (MEBASE +   8);
  ERROR_INVALID_NUMSLAVES           = (MEBASE +   9);
  ERROR_INVALID_REQUEST             = (MEBASE +  10);
  ERROR_INVALID_SPCBKEY             = (MEBASE +  11);
  ERROR_INVALID_HNDLR_NAME          = (MEBASE +  12);
  ERROR_INVALID_PROTOCOL            = (MEBASE +  13);
  ERROR_INVALID_BUFFER_SIZE         = (MEBASE +  14);
  ERROR_INVALID_BUFFER_RETURNED     = (MEBASE +  15);
  ERROR_INVALID_ACB                 = (MEBASE +  16);
  ERROR_INVALID_RECORD_RETURNED     = (MEBASE +  17);
  ERROR_INVALID_MESSAGE             = (MEBASE +  18);
  ERROR_STREAM_NOT_OWNER            = (MEBASE +  99);
  ERROR_STREAM_USED                 = (MEBASE + 100);
  ERROR_STREAM_CREATION             = (MEBASE + 101);
  ERROR_STREAM_NOTMASTER            = (MEBASE + 102);
  ERROR_STREAM_NOT_STOP             = (MEBASE + 103);
  ERROR_STREAM_OPERATION            = (MEBASE + 104);
  ERROR_STREAM_STOP_PENDING         = (MEBASE + 105);
  ERROR_STREAM_ALREADY_STOP         = (MEBASE + 106);
  ERROR_STREAM_ALREADY_PAUSE        = (MEBASE + 107);
  ERROR_STREAM_NOT_STARTED          = (MEBASE + 108);
  ERROR_STREAM_NOT_ACTIVE           = (MEBASE + 109);
  ERROR_START_STREAM                = (MEBASE + 110);
  ERROR_MASTER_USED                 = (MEBASE + 111);
  ERROR_SPCBKEY_MISMATCH            = (MEBASE + 112);
  ERROR_INSUFF_BUFFER               = (MEBASE + 113);
  ERROR_ALLOC_RESOURCES             = (MEBASE + 114);
  ERROR_ACCESS_OBJECT               = (MEBASE + 115);
  ERROR_HNDLR_REGISTERED            = (MEBASE + 116);
  ERROR_DATA_ITEM_NOT_SPECIFIED     = (MEBASE + 117);
  ERROR_INVALID_SEQUENCE            = (MEBASE + 118);
  ERROR_INITIALIZATION              = (MEBASE + 119);
  ERROR_READING_INI                 = (MEBASE + 120);
  ERROR_LOADING_HNDLR               = (MEBASE + 121);
  ERROR_HNDLR_NOT_FOUND             = (MEBASE + 122);
  ERROR_SPCB_NOT_FOUND              = (MEBASE + 123);
  ERROR_DEVICE_NOT_FOUND            = (MEBASE + 124);
  ERROR_TOO_MANY_EVENTS             = (MEBASE + 125);
  ERROR_DEVICE_OVERRUN              = (MEBASE + 126);
  ERROR_DEVICE_UNDERRUN             = (MEBASE + 127);
  ERROR_HNDLR_NOT_IN_INI            = (MEBASE + 128);
  ERROR_QUERY_STREAM_TIME           = (MEBASE + 129);
  ERROR_DATA_ITEM_NOT_SEEKABLE      = (MEBASE + 130);
  ERROR_NOT_SEEKABLE_BY_TIME        = (MEBASE + 131);
  ERROR_NOT_SEEKABLE_BY_BYTES       = (MEBASE + 132);
  ERROR_STREAM_NOT_SEEKABLE         = (MEBASE + 133);
  ERROR_PLAYLIST_STACK_OVERFLOW     = (MEBASE + 135);
  ERROR_PLAYLIST_STACK_UNDERFLOW    = (MEBASE + 136);
  ERROR_LOCKING_BUFFER              = (MEBASE + 137);
  ERROR_UNLOCKING_BUFFER            = (MEBASE + 138);
  ERROR_SEEK_PAST_END               = (MEBASE + 139);
  ERROR_SEEK_BACK_NOT_SUPPORTED     = (MEBASE + 140);
  ERROR_INTERNAL_ERROR              = (MEBASE + 141);
  ERROR_INTERNAL_CORRUPT            = (MEBASE + 142);
  ERROR_INSUFF_MEM                  = (MEBASE + 143);
  ERROR_LARGE_SEEK_BY_TIME          = (MEBASE + 144);
  ERROR_STREAM_PREROLLING           = (MEBASE + 145);
  ERROR_INI_FILE                    = (MEBASE + 146);
  ERROR_SEEK_BEFORE_BEGINNING       = (MEBASE + 147);
  ERROR_TOO_MANY_HANDLERS           = (MEBASE + 148);
  ERROR_ALLOC_HEAP                  = (MEBASE + 149);
  ERROR_END_OF_PLAYLIST             = (MEBASE + 150);
  ERROR_TOO_MANY_STREAMS            = (MEBASE + 151);
  ERROR_FILE_FORMAT_INCORRECT       = (MEBASE + 152);
  ERROR_DESTROY_STREAM              = (MEBASE + 153);
  ERROR_INVALID_NUMMASTERS          = (MEBASE + 154);
  ERROR_MASTER_CONFLICT             = (MEBASE + 155);
  ERROR_NO_MASTER                   = (MEBASE + 156);
  ERROR_NO_SYNC                     = (MEBASE + 157);
  ERROR_BUFFER_NOT_AVAILABLE        = (MEBASE + 400);
  ERROR_TOO_MANY_BUFFERS            = (MEBASE + 401);
  ERROR_TOO_MANY_RECORDS            = (MEBASE + 402);

  // ERROR_INVALID_PROTOCOL ulErrorStatus Defines
  // Refer to SHC_NEGOTIATE_RESULT api function
  PROTOCOL_SPCBLENGTH               =  1;
  PROTOCOL_SPCBKEY                  =  2;
  PROTOCOL_DATAFLAG                 =  3;
  PROTOCOL_NUMRECORDS               =  4;
  PROTOCOL_BLOCKSIZE                =  5;
  PROTOCOL_BUFFERSIZE               =  6;
  PROTOCOL_MINNUMBUFFERS            =  7;
  PROTOCOL_MAXNUMBUFFERS            =  8;
  PROTOCOL_SOURCESTART              =  9;
  PROTOCOL_TARGETSTART              = 10;
  PROTOCOL_BUFFERFLAG               = 11;
  PROTOCOL_HANDLERFLAG              = 12;
  PROTOCOL_SYNCTOLERANCE            = 13;
  PROTOCOL_SYNCINTERVAL             = 14;
  PROTOCOL_INTERNALERROR            = -1;

  // MMIO Manager error return codes
  MMIOERR_BASE                      = (MEBASE + 1000);
  MMIOERR_UNBUFFERED                = (MMIOERR_BASE +  1);
  MMIOERR_CANNOTWRITE               = (MMIOERR_BASE +  2);
  MMIOERR_CHUNKNOTFOUND             = (MMIOERR_BASE +  3);
  MMIOERR_INVALID_HANDLE            = (MMIOERR_BASE +  4);
  MMIOERR_INVALID_PARAMETER         = (MMIOERR_BASE +  5);
  MMIOERR_INTERNAL_SYSTEM           = (MMIOERR_BASE +  6);
  MMIOERR_NO_CORE                   = (MMIOERR_BASE +  7);
  MMIOERR_INI_OPEN                  = (MMIOERR_BASE +  8);
  MMIOERR_INI_READ                  = (MMIOERR_BASE +  9);
  MMIOERR_INVALID_BUFFER_LENGTH     = (MMIOERR_BASE + 10);
  MMIOERR_NO_BUFFER_ALLOCATED       = (MMIOERR_BASE + 11);
  MMIOERR_NO_FLUSH_FOR_MEM_FILE     = (MMIOERR_BASE + 12);
  MMIOERR_NO_FLUSH_NEEDED           = (MMIOERR_BASE + 13);
  MMIOERR_READ_ONLY_FILE            = (MMIOERR_BASE + 14);
  MMIOERR_WRITE_ONLY_FILE           = (MMIOERR_BASE + 15);
  MMIOERR_INSTALL_PROC_FAILED       = (MMIOERR_BASE + 16);
  MMIOERR_READ_FAILED               = (MMIOERR_BASE + 17);
  MMIOERR_WRITE_FAILED              = (MMIOERR_BASE + 18);
  MMIOERR_SEEK_FAILED               = (MMIOERR_BASE + 19);
  MMIOERR_CANNOTEXPAND              = (MMIOERR_BASE + 20);
  MMIOERR_FREE_FAILED               = (MMIOERR_BASE + 21);
  MMIOERR_EOF_SEEN                  = (MMIOERR_BASE + 22);
  MMIOERR_INVALID_ACCESS_FLAG       = (MMIOERR_BASE + 23);
  MMIOERR_INVALID_STRUCTURE         = (MMIOERR_BASE + 24);
  MMIOERR_INVALID_SIZE              = (MMIOERR_BASE + 25);
  MMIOERR_INVALID_FILENAME          = (MMIOERR_BASE + 26);
  MMIOERR_CF_DUPLICATE_SEEN         = (MMIOERR_BASE + 27);
  MMIOERR_CF_ENTRY_NO_CORE          = (MMIOERR_BASE + 28);
  MMIOERR_CF_WO_UNSUPPORTED         = (MMIOERR_BASE + 29);
  MMIOERR_CF_ELEMENTS_OPEN          = (MMIOERR_BASE + 30);
  MMIOERR_CF_NON_BND_FILE           = (MMIOERR_BASE + 31);
  MMIOERR_CF_ENTRY_NOT_FOUND        = (MMIOERR_BASE + 32);
  MMIOERR_DELETE_FAILED             = (MMIOERR_BASE + 33);
  MMIOERR_OUTOFMEMORY               = (MMIOERR_BASE + 34);
  MMIOERR_INVALID_DLLNAME           = (MMIOERR_BASE + 35);
  MMIOERR_INVALID_PROCEDURENAME     = (MMIOERR_BASE + 36);
  MMIOERR_MATCH_NOT_FOUND           = (MMIOERR_BASE + 37);
  MMIOERR_SEEK_BEFORE_BEGINNING     = (MMIOERR_BASE + 38);
  MMIOERR_INVALID_FILE              = (MMIOERR_BASE + 39);
  MMIOERR_QOSUNAVAILABLE            = (MMIOERR_BASE + 40);
  MMIOERR_MEDIA_NOT_FOUND           = (MMIOERR_BASE + 41);
  MMIOERR_ERROR_IN_FRAME_DATA       = (MMIOERR_BASE + 42);
  MMIOERR_INVALID_DIM_ALIGN         = (MMIOERR_BASE + 43);
  MMIOERR_CODEC_NOT_SUPPORTED       = (MMIOERR_BASE + 44);

  MMIOERR_UNSUPPORTED_FUNCTION      = (MMIOERR_BASE + 45);
  MMIOERR_CLIPBRD_ERROR             = (MMIOERR_BASE + 46);
  MMIOERR_CLIPBRD_ACTIVE            = (MMIOERR_BASE + 47);
  MMIOERR_CLIPBRD_EMPTY             = (MMIOERR_BASE + 48);
  MMIOERR_NEED_NEW_FILENAME         = (MMIOERR_BASE + 49);
  MMIOERR_INVALID_TRACK_OPERATION   = (MMIOERR_BASE + 50);
  MMIOERR_INCOMPATIBLE_DATA         = (MMIOERR_BASE + 51);
  MMIOERR_ACCESS_DENIED             = (MMIOERR_BASE + 52);
  MMIOERR_MISSING_FLAG              = (MMIOERR_BASE + 53);
  MMIOERR_INVALID_ITEM_FLAG         = (MMIOERR_BASE + 54);

  // User defined error return codes
  USERERR_BASE                      = (MMIOERR_BASE + 1000);

{-----[ MCIAPI ]----}

function mciPlayFile(hwndOwner: HWnd;           // Ownerwindow
                     pszFile: PChar;            // File
                     ulFlags: uLong;            // Flags
                     pszTitle: PChar;           // Title
                     hwndViewport: HWnd): ULong;// Viewport Window

function mciPlayResource(hwndOwner: HWnd;       // Owner Window
                         hmod: hModule;         // Module
                         resType: uLong;        // Resource Type
                         resID: uLong;          // Resource ID
                         ulFlags: uLong;        // Flags
                         pszTitle: pChar;       // Title
                         hwndViewport: HWnd): ULong;   // Viewport Window

function mciRecordAudioFile(hwndOwner: HWnd; pszFile, pszTitle: pCHar;
  ulFlags: uLong): uLong;

// Audio Macro Service Routines
function mmioRemoveElement(pszFileElement: pChar; ulFlag: uLong): Ulong;

function mmioFindElement(ulCode: ULong;         // Find Code
                         pszElement: pChar;     // Element
                         ulElementLen: uLong;   // Element Buffer Length
                         pszFile: pChar;
                         ulReserved: ULong)     // Compound File
                                            : uLong;

const
  MMIO_FE_FINDFIRST        = 1;
  MMIO_FE_FINDNEXT         = 2;
  MMIO_FE_FINDEND          = 3;
  MMIO_FE_FINDELEMENT      = 4;

  MMIO_RE_COMPACT          = 1;

  // Flags for mciPlayFile
  MCI_OWNERISPARENT        = $0001;      // digital and overlay
  MCI_STOPACTIVE           = $0002;      // stop playing whatever is playing
  MCI_ASYNCRENDEZVOUS      = $0004;      // play and return immediately
  MCI_RENDEZVOUS           = $0008;      // wait til prev is finished then play
  MCI_ASYNC                = $0010;      // no syncup will be done

{----[ SSM ]----}

// Sync/Stream Manager Definitions

const
  Max_SPI_Name             = 9;          // Maximum ASCIIZ stream handler name/class and device driver name

type
  hStream = uLong;               // Stream Handle
  phStream = ^hStream;           // Pointer to Stream Handle

  hEvent = uLong;                // Event Handle
  phEvent = ^hEvent;             // Pointer to Event Handle

  hID = uLong;                   // Stream Handler ID
  // The following define was deleted because it conflicts with an OS/2 PM define
  // phID = ^hID;                // Pointer to Stream Handler ID

  LockH = record                 // Memory locking handle (used by PDD)
    Lock: Array[0..15] of Byte;
  end;
  pLockH = ^LockH;

  rc = uLong;                    // Used for all return codes

  Slave = record
   hstreamSlave: hStream;        // Handle for this slave
   mmtimeStart: mmTime;          // Offset in master stream time to start this slave
  end;
  pSlave = ^Slave;

  Master = record
    hstreamMaster: hStream;        // Handle for this master
  end;
  pMaster = ^Master;

  Hand = record
    szHandlerClass: Array[0..MAX_SPI_NAME-1] of char; // Stream handler class
    szHandlerName:  Array[0..MAX_SPI_NAME-1] of char; // Stream handler name
  end;
  pHand = ^Hand;

{----[ SSM / SPCB ]----}

// Control Block Definitions

type
  // SPCB - Stream Protocol Control Block
  spcb = record
   ulSPCBLen       : uLong;       // SPCB struture length
   spcbkey         : SPCBKEY;
   ulDataFlags     : uLong;       // Data type flags
   ulNumRec        : uLong;       // Max # records/buffer (Only used for Split streams)
   ulBlockSize     : uLong;       // Block alignment in bytes.
   ulBufSize       : uLong;       // Buffer size (SSM allocated buffers) must be
                                  //  a multiple of Block size
   ulMinBuf        : uLong;       // Minimum number of buffers needed to stream
   ulMaxBuf        : uLong;       // Maximum number of buffers needed to stream
   ulSrcStart      : uLong;       // # of EMPTY buffers required to start Source
   ulTgtStart      : uLong;       // # of FULL buffers required to start Target
   ulBufFlags      : uLong;       // Handler Protocol negotiation flags
   ulHandFlags     : uLong;       // Handler Protocol flags
   mmtimeTolerance : mmTime;      // Sync tolerance value...Used as check by SSM
                                  //  to determine whether to send a sync pulse
                                  //  to this specific slave Stream Handler.
                                  //  Algorithm:
                                  //   diff = abs(master time - slave time)
                                  //   if  diff >= tolerance
                                  //     then send sync pulse
                                  // (Valid only for Slave stream handlers)
   mmtimeSync      : mmTime;      // Used to save sync pulse generation granularity
                                  //  if the master uses the Stream Manager Timer.
                                  //  if SpiSetSync passed NULL value for sync gran
                                  //   then use this default value. (since hardware
                                  //   must have it's own interrupt time interval.
                                  // (Valid only for Master stream handlers)
   ulBytesPerUnit  : uLong;       // Bytes/unit of time. This is used to do seeks
                                  // on linear data that is not compressed or
                                  // of variable length.
   mmtimePerUnit   : mmTime;      // The amount of mmtime each unit represents.
                                  // A unit can be a second, minute or whatever.
  end;
  pspcb = ^spcb;

const
  spcb_max_buf_Size        = 1024*1024;  // Largest buffer size in bytes

  // SPCB_ulDataFlags:
  spcbData_CueTime         = $0002; // This data type can support time cue points
  spcbData_CueData         = $0004; // This data type can support data cue points

  spcbData_Seek            = $0000; // Seeks can be performed on this data type.
  spcbData_NoSeek          = $0008; // NO seeks can be performed on this data type.
  spcbData_YieldTime       = $0010; // The ulBytes per unit field is used for a millisecond value
                                    // It represents the amount of yield time between reads of
                                    // each buffer. If this bit is set, the value of ulBytesPerUnit
                                    // is used as input to DosSleep to yield for that period of time
  ValidDataFlags           = spcbData_CueTime OR spcbData_CueData OR
                             spcbData_YieldTime OR spcbData_NoSeek;

  // SPCB_ulBufFlags:
  spcbBuf_USERPROVIDED     = $0001; // User provides buffers for stream
                                    // SSMgr will not allocate buffers,
                                    // but must lock down provided buffers,
                                    // so this will affect performance!!
                                    // (Source Handler only)
  spcbBuf_FIXEDBUF         = $0002; // Buffer size is fixed for this data type
                                    //  in this handler. Can not be used
                                    //  with the spcbBuf_USERPROVIDED flags.
  spcbBuf_NONCONTIGUOUS    = $0004; // Buffer do not need to be contiguous
                                    //  in physical memory.
  spcbBuf_INTERLEAVED      = $0008; // Stream buffers can be interleaved.
                                    //  Can not be use with the
                                    //  spcbBuf_USERPROVIDED flag.
                                    //  (Source Handler only)
  spcbBuf_MAXSIZE          = $0010; // ulBufSize is the maximum size that
                                    //  can be used by this stream handler
  spcbBuf_16MEG            = $0020; // The Stream buffers may be allocated
                                    //  above the 16 Meg line. This is used
                                    //  by stream handlers that can support
                                    //  greater than 16 Megabyte addresses.
  spcbBuf_FIXEDBLOCK       = $0040; // Use the ulBlockSize field to represent
                                    // the size of the IO reads that should
                                    // be performed (Interleaved streams)
  ValidBufFlags            = spcbBuf_UserProvided OR spcbBuf_FixedBuf OR
                             spcbBuf_NonContiguous OR spcbBuf_Interleaved OR
                             spcbBuf_16Meg OR spcbBuf_FixedBlock OR
                             spcbBuf_MaxSize;

  // SPCB_ulHandFlags:
  spcbHand_genSync         = $0001; // (INPUT FROM HANDLER ONLY)
                                    // This handler can generate sync pulses
                                    // if it is the master.
  spcbHand_RcvSync         = $0002; // (INPUT FROM HANDLER ONLY)
                                    // This handler can receive sync pulses
                                    // if it is a slave
  spcbHand_Timer           = $0004; // Use Stream Manager Timer for Sync
  spcbHand_NonStream       = $0008; // Stream Handler is non-streaming
  spcbHand_GenTime         = $0010; // This handler contains real
                                    // stream time. The handler that
                                    // supports the SpiGetTime, data/time
                                    // cue point calls for this stream.
  spcbHand_NoPreRoll       = $0020; // This stream can not be prerolled.
                                    // (i.e. recording streams)
  spcbHand_NoSync          = $0040; // This stream can be group into a
                                    // sync group, but does not send or
                                    // receive sync pulses.
  spcbHand_Phys_Seek       = $0080; // This handler does a seek to a physical
                                    // device or memory not just a time adjustment.
                                    // (ssm will always call this handler first on
                                    //  an SpiSeekStream call).

  ValidHandFlags           = spcbHand_GenSync OR spcbHand_RcvSync OR
                             spcbHand_Timer OR spcbHand_NonStream OR
                             spcbHand_GenTime OR spcbHand_NoPreRoll OR
                             spcbHand_NoSync OR spcbHand_Phys_Seek;


{----[ SSM / EVCB ]----}

// Block definitions

{ *********************************************
  * List of Implicit events:
  *    EVENT_EOS                 - Use IMPL_EVCB
  *    EVENT_ERROR               - Use IMPL_EVCB
  *    EVENT_STREAM_STOPPED      - Use IMPL_EVCB
  *    EVENT_SYNC_PREROLLED      - Use IMPL_EVCB
  *    EVENT_PLAYLISTMESSAGE     - Use PLAYL_EVCB
  *    EVENT_PLAYLISTCUEPOINT    - Use PLAYL_EVCB
  *    EVENT_QUEUE_OVERFLOW      - Use IMPL_EVCB
  ********************************************* }

{ *********************************************
  * List of Explicit events:
  *    EVENT_SYNCOVERRUN         - Use OVRU_EVCB
  *    EVENT_CUE_TIME            - Use TIME_EVCB
  *    EVENT_CUE_DATA            - Use DATA_EVCB
  *    EVENT_DATAUNDERRUN        - Use EVCB
  *    EVENT_DATAOVERRUN         - Use EVCB
  *    EVENT_CUE_TIME_PAUSE      - Use TIME_EVCB
  ********************************************* }

const
  Event_SYNCOVERRUN        = 4;
  Event_CUE_TIME           = 5;       // Cue point in terms of stream time
  Event_CUE_DATA           = 6;       // Cue point in terms of data items
  Event_DATAUNDERRUN       = 7;       // data underrun event from SH
  Event_DATAOVERRUN        = 8;       // data underrun event from SH
  Event_CUE_TIME_PAUSE     = 9;       // Pause when cue-point reached.
  Event_STATUS_LEVEL       = 10;      // Report status level

{*********************************************
 * SYNC_EVCB - Sync Pulse Event Control Block
 *             (This event is only seen by
 *              stream handlers)
 *********************************************}
  Event_SYNC               = 1;       // Synchronization point in stream
type
  sync_evcb = record
    ulType       : uLong;             // Event_SYNC
    ulSubType    : uLong;             // Not used
    ulSyncFlags  : uLong;             // 0 (input),status (output)
    hstream      : HStream;           // handle to stream for this event
    hid          : hID;               // Handler id
    ulStatus     : uLong;             // Event status (output)
    mmtimeStart  : mmTime;            // Filled in by Sync/Stream manager
                                      //  at SpiEnableSync time. (input)
    mmtimeMaster : mmTime;            // Filled in by Master SH (input)
    mmtimeSlave  : mmTime;            // Filled in by slave SH. (output)
  end;
  pSync_evcb = ^sync_Evcb;

const
  // ulSyncFlags
  SyncOverrun              = $0001;   // Set by SSM if sync pulse comes in before
                                      //  a has processed the current sync pulse.
  SyncPolling              = $0002;   // SSM set this after filling the handler EVCB.
                                      //  Handler resets it after it processes the
                                      //  contents of EVCB. The SSM must check this
                                      //  bit before modifying EVCB. If bit already
                                      //  set, set the SYNC overrun bit.

  Event_Reserved           = 2;       // RESERVED


{*********************************************
 * IMPL_EVCB - Implicit Event Control Block
 *             (This is a parameter on the
 *              SpiCreatStrem API)
 *********************************************}
  Event_Implicit_Type      = 3;      // These events are always supported

type
  impl_evcb = record
    ulType     : uLong;              // Event_IMPLICIT_TYPE
    ulSubType  : uLong;              // One of the implicit events (input)
    ulFlags    : uLong;              // 0 (Input), status (Output)
    hstream    : hStream;            // handle to stream for this event (input/output)
    hid        : hID;                // 0 (input), handler Id (output)
    ulStatus   : uLong;              // Event status/error return code (output)
    unused1    : uLong;              // 0 (input)
    unused2    : uLong;              // 0 (input)
    unused3    : uLong;              // 0 (input)
  end;
  pImpl_evcb = ^impl_evcb;

const
  // ulSubtype
 Event_EOS                 = 1;      // End of Stream
 Event_ERROR               = 2;      // Error in Stream handler or device driver
 Event_STREAM_STOPPED      = 3;      // Stream is in a stopped state (Discard or Flush)
 Event_SYNC_PREROLLED      = 4;      // All streams are prerolled (buffers
                                     //  have been filled by the Source SH's.
 Event_PLAYLISTMESSAGE     = 5;      // Memory SH playlist message event
 Event_PLAYLISTCUEPOINT    = 6;      // Memory SH playlist cue point
 Event_QUEUE_OVERFLOW      = 7;      // Event Queue overflow. Indicates lost
                                     //  events. Application must use this
                                     //  to clear any waiting conditions.

{*********************************************
 * PLAYL_EVCB - Playlist Message Event Control Block
 *********************************************}
type
  // (IMPLICIT EVENT)
  PlayL_evcb = record
    ulType         : uLong;             // Event_IMPLICIT_TYPE
    ulSubType      : uLong;             // Event_PLAYLISTMESSAGE or Event_PLAYLISTCUEPOINT
    ulFlags        : uLong;             // 0 (input), status (output)
    hstream        : hStream;           // handle to stream for this event (input/output)
    hid            : hID;               // 0 (input), handler Id (output)
    ulStatus       : uLong;             // Playlist Instruction number (output)
    ulMessageParm  : uLong;             // 0 (input), Message from playlist (output)
    unused1        : uLong;             // 0 (input)
    unused2        : uLong;             // 0 (input)
  end;
  pPlayL_evcb = ^PlayL_evcb;

{*********************************************
 * OVRU_EVCB - Sync Overrun Event Control Block
 *             (Applications can request to be
 *              notified whenever a Sync overrun
 *              occurs.
 *********************************************}
  Ovru_evcb = record
    ulType        : uLong;             // Event_SYNCOVERRUN
    ulSubType     : uLong;             // Not used
    ulFlags       : uLong;             // 0 (input), status (output)
    hstream       : hStream;           // handle to stream for this event (input/output)
    hid           : hID;               // handler Id (input/output)
    ulStatus      : uLong;             // Event status/error return code (output)
    mmtimeSlave   : mmTime;            // 0 (input), Slave stream time (output)
    mmtimeStart   : mmTime;            // 0 (input), Slave start offset (offset)
    mmtimeMaster  : mmTime;            // 0 (input), Master stream time (output)
  end;
  pOvru_evcb = ^Ovru_evcb;

{*********************************************
 * TIME_EVCB - Cue Time Event Control Block
 *             (Applications can request to be
 *              notified for a time cue point)
 *********************************************}
  time_evcb = record
    ulType         : uLong;            // Event_CUE_TIME
    ulSubType      : uLong;            // Not used
    ulFlags        : uLong;            // Single/Recurring(input/output)
    hstream        : HSTREAM;          // handle to stream for this event (input/output)
    hid            : hID;              // handler Id (input/output)
    ulStatus       : uLong;            // Event status/error return code (output)
    mmtimeStream   : MMTIME;           // Stream time (input/output)
    unused1        : uLong;            // 0 (input)
    unused2        : uLong;            // 0 (input)
  end;
  ptime_evcb = ^time_evcb;

const
  // ulFlags:
  Event_SINGLE             = 0;        // This is single one time event
  Event_RECURRING          = 1;        // This is recurring event

{*********************************************
 * DATA_EVCB - Cue Data Event Control Block
 *             (Applications can request to be
 *              notified for a data cue point)
 *********************************************}
type
  data_evcb = record
    ulType        : uLong;             // Event_CUE_DATA
    ulSubType     : uLong;             // Event SubType
    ulFlags       : uLong;             // Single/Recurring(input/output)
    hstream       : HSTREAM;           // handle to stream for this event (input/output)
    hid           : hID;               // handler Id (input/output)
    ulStatus      : uLong;             // Event status/error return code (output)
    mmtimeStream  : mmTime;            // Stream time (input/output)
    ulEventParm1  : uLong;             // Data to Cue on (input/output)
                                       //  This is interpreted by the stream handler
    ulEventParm2  : uLong;             // Length of data cue buffer (input/output)
  end;
  pdata_evcb = ^data_evcb;

const
  // ulFlags:
  Event_DATAPTR            = 2;        // ulEventParm1 if ptr to buffer and
                                       //  ulEventParm2 is a length of buffer,
                                       //  else ulEventParm1 is data.

{*****************
 * EVCB_ulType:  (Stream Handler defined types)
 *****************}
  sh_Type                  = $80000000;// Stream Handler defined types must
                                       // have the high order bit set in the
                                       // ulType field.
                                       // events: 0H - 7FFFFFFFH are reserved!

{*********************************************
 * EVCB - Generic Event Control Block (Use the
 *        specific one in the SSM.H if possible)
 *********************************************}
type
  evcb = record
    ulType       : uLong;              // Event type (input)
    ulSubType    : uLong;              // Event SubType (input)
    ulFlags      : uLong;              // 0 (Input), status (Output)
    hstream      : HSTREAM;            // handle to stream for this event
    hid          : hID;                // handler Id (input/output)
    ulStatus     : uLong;              // Event status (output)
    ulEventParm1 : uLong;              // Event parameters (input), hID if implicit event
    ulEventParm2 : uLong;              // Event parameters (input)
    ulEventParm3 : uLong;              // Event parameters (input)
  end;
  pevcb = ^evcb;

{*********************************************
 * STATUS_LEVEL_EVCB - Status Level Event Control Block
 *********************************************}
  Status_Level_evcb = record
    // standard part
    ulType          : uLong;            // Event type (input)
    ulSubType       : uLong;            // Event SubType (input)
    pMCDInstance    : uLong;            // for MCD use
    hstream         : hStream;          // handle to stream for this event
    hid             : hID;              // handler Id (input/output)
    // custom part
    ulSample        : Array[0..3] of uLong; // Samples
  end;
  pStatus_Level_evcb = ^Status_Level_evcb;

{----[ SSM / ACB ]----}

// Associate Control Block Definitions

const
  Max_Port_Name            = 40;        // Max port name length
  Max_Ports                = 16;        // Max number ports

{**********************************************
 *
 * ACB - Associate Control Block
 *
 *       Each stream handler must define the
 *       ACB for each data object type that
 *       expect ACB's from the application.
 *
 **********************************************}
type
  ACB = record                          // acb  -  Assoc. Control Block
    ulACBLen   : uLong;                 // length of structure
    ulObjType  : uLong;
    ulParm1    : uLong;
    ulParm2    : uLong;
  end;
  pACB = ^ACB;

{*****************************************************
 * FSSH - File system stream handler MMIO Object ACB
 *****************************************************}
const
  ACBType_mmIO             = $0001;     // MMIO object

type
  ACB_mmIO = record                     // acbmmio  - MMIO Assoc. Control Block
    ulACBLen  : uLong;                  // length of structure
    ulObjType : uLong;                  // ACBTYPE_MMIO
    hmmio     : HMMIO;                  // Handle of media element mgr obj
  end;
  pACB_mmIO = ^ACB_mmIO;

{*****************************************************
 * MSH - Memory stream handler Playlist Object ACB
 *****************************************************}
const
  ACBType_Mem_PlayL        = $0003;     // Memory playlist object

type
  ACB_Mem_PlayL = record                // acbplyl - File system Assoc. Control Block
    ulACBLen    : uLong;                // length of structure
    ulObjType   : uLong;                // ACBType_MEM_PLAYL
    pMemoryAddr : Pointer;              // Starting address of memory obj
  end;
  pACB_Mem_PlayL = ^ACB_Mem_PlayL;

{*****************************************************
 * CDDASH - CD DA stream handler Object ACB
 *****************************************************}
const
  ACBType_CDDA             = $0004;     //  Compact disk - digital audio obj

type
  ACB_CDDA = record                     // acbcdda - CD Assoc. Control Block
    ulACBLen   : uLong;                 // length of structure
    ulObjType  : uLong;                 // ACBType_CDDA
    bCDDrive   : CHAR;                  // CD drive letter
  end;
  pACB_CDDA = ^ACB_CDDA;

{*****************************************************
 * MISH - MIDI stream handler port-stream table ACB
 *****************************************************}
const
  ACBType_MISH             = $0005;     // MIDI port-stream table

type
  ACB_Mish = record                     // acbmish - MIDI Assoc. Control Block
    ulACBLen        : uLong;            // length of structure
    ulObjType       : uLong;            // ACBType_MISH
    hstreamDefault  : HSTREAM;          // Default hstream to use when mapper
                                        // is turned off.
    ulDeviceTypeID  : uLong;            // device type id
    ulpMapperPorts  : uLong;            // pointer to mapper port table
    ulNumInStreams  : uLong;
    hstreamIn       : Array[1..Max_Ports] of hStream; // Array of Input streams
    ulNumOutStreams : uLong;
    hstreamOut      : Array[1..Max_Ports] of hStream; // Array of Output streams
                                        // The index into the array is
                                        // the source channel for that
                                        // stream.
  end;
  pACB_Mish = ^ACB_Mish;

{*****************************************************
 * MISH - MIDI stream handler SET ACB
 *****************************************************}
const
  ACBType_SET              = $0006;     // MIDI set function

type
  ACB_Set = record                      // acbset - Set Assoc. Control Block
    ulACBLen   : uLong;                 // length of structure
    ulObjType  : uLong;                 // ACBType_SET
    ulFlags    : uLong;                 // Set flags
    ulReserved : uLong;                 // Reserved
  end;
  pACB_Set = ^ACB_Set;

const
  // ulFlags defines
  MIDI_MAP_ON              = $0000;     // turn mapping function on in MISH
  MIDI_MAP_OFF             = $0001;     // turn mapping function off in MISH

{*****************************************************
 * NULLSH - Null stream handler user ACB
 *****************************************************}
const
  ACBType_NULLSH           = $0007;     // User od Null stream handler

type
  ACB_NullSH = record                   // acbnullsh - NULLSH Assoc. Control Block
    ulACBLen   : uLong;                 // length of structure
    ulObjType  : uLong;                 // ACBType_NULLSH
    pfnEntry   : PFN;                   // user callback entry point
    ulReserved : uLong;                 // Reserved
  end;
  pACB_NullSh = ^ACB_NullSh;

{*****************************************************
 * MTSH - MultiTrack Stream Handler Object ACB
 *****************************************************}
const
  ACBType_MTSH             = $0008;     // MTSH object

type
  ACB_MTSH = record                     // acbmtsh  - MTSH Assoc. Control Block
    ulACBLen         : uLong;           // length of structure
    ulObjType        : uLong;           // ACBType_MTSH
    hmmio            : HMMIO;           // Handle of media element mgr obj
    mmtrackInfo      : MMTRACKINFO;     // track for this stream
    ulFlags          : uLong;           // flags
    ulMaxBytesPerSec : uLong;           // Max bytes per second
    ulAvgBytesPerSec : uLong;           // Avg bytes per second
    mmtimePerFrame   : MMTIME;          // frame display time or 0L
    ulTotalFrames    : uLong;           // total number of video frames
  end;
  pACB_MTSH = ^ACB_MTSH;

const
  // ulFlags defines
  Track_ACTIVATE           = $0000;     // Activate track in stream handler
  Track_DEACTIVATE         = $0001;     // Deactivate track in stream handler


{*****************************************************
 * CSH - CODEC stream handler Object ACB
 *****************************************************}
const
  ACBType_CODECSH          = $0009;     // CODEC object

type
  ACB_CodecSH = record                  // acbcodecsh - CODEC SH acb
    ulACBLen        : uLong;            // length of structure
    ulObjType       : uLong;            // ACBType_CODECSH
    hstreamToPair   : HSTREAM;          // 2nd stream of pair
    pMmioInfo       : Pointer;          // info for IO Proc
    ulInfoLength    : uLong;            // length of MmioInfo
    pCodecControl   : Pointer;          // CODEC control info
    ulControlLength : uLong;            // length of CodecControl
  end;
  pACB_CodecSH = ^ACB_CodecSH;

{----[ SSM / DCB ]----}

// Device Control Block Definitions

{**************************************************************************
 *
 * DCB - Common Device Control Block
 *               (*** PACKED STRUCTURE ***)
 **************************************************************************}
type
  DCB = record                          // dcb  -  Device Control Block
    ulDCBLen  : uLong;                  // length of structure
    szDevName : Array[0..MAX_SPI_NAME-1] of Char; // device driver name
  end;
  pDCB = ^DCB;

{**************************************************************************
 *
 * E_DCB - Extended Device Control Block
 *
 *         This structure will grow over time as new fields are added
 *         to the end of the structure.  If you manipulate the structure,
 *         be sure to check the length field.
 *
 *               (*** PACKED STRUCTURE ***)
 **************************************************************************}
 E_DCB = record                         // e_dcb  -  Extended Device Control Block
   ulDCBLen     : uLong;                // length of structure
   szDevName    : Array[0..MAX_SPI_NAME-1] of char; // device driver name
   ulSysFileNum : uLong;                // file handle number

   //    new fields will be added here
 end;
 DCB_AudioSH = E_DCB;
 pE_DCB = ^E_DCB;
 pDCB_AudioSH = ^DCB_AudioSH;

{**************************************************************************
 *
 * VSD_DCB - VSD Device Control Block
 *
 *         This structure will allow stream handlers to use the VSD DLL
 *         by using by the additional fields in the structure.
 *
 *               (*** PACKED STRUCTURE ***)
 **************************************************************************}
  VSD_DCB = record                      // vsd_dcb - VSD Device Control Block
    ulDCBLen         : uLong;           // length of structure
    szDevName        : Array[0..MAX_SPI_NAME-1] of Char; // device driver name
    ulSysFileNum     : uLong;           // file handle number
    hvsd             : uLong;           // Handle to VSD instance
    pfnvsdEntryPoint : PFN;             // Address of VSD entry point
    ulReserved1      : uLong;           // Reserved for system
    ulReserved2      : uLong;           // Reserved for system
  end;
  pVSD_DCB = ^VSD_DCB;

{----[ SSM, cont'd ]----}

{**************************************************************************
  INI file support defines
 **************************************************************************}
const
  // RCDATA defines
  SPI_RESOURCE                  = 1;    // RCDATA resource number
  SH_DLL_TYPE                   = 0;    // DLL type stream handler
  SH_PDD_TYPE                   = 1;    // PDD type stream handler
  SPCBSIZE                      = 72;   // SPCB length, the Resource compiler
                                        //   doesn't allow sizeof(SPCB).

(**************************************************************************
//
//  Function Prototypes for Application event entry routine, SHC entry
//  routine, SMH entry routine. All use the Pure C calling convention
//
//**************************************************************************
typedef uLong (APIENTRY EVFN) (PEVCB  pevcb);
typedef EVFN (FAR *PEVFN);

typedef uLong (APIENTRY SHCFN) (pVoid pParmIn);
typedef SHCFN (FAR *PSHCFN);

typedef uLong (APIENTRY SMHFN) (pVoid pParmIn);
typedef SMHFN (FAR *PSMHFN);*)

type
  pEvfn = Pointer;
  pShcfn = Pointer;
  pSmhfn = Pointer;

{**************************************************************************
  Function Prototypes for SPI functions
  All use Pure C calling convention
  Six major categories:
     - stream creation
     - stream control
     - event handling
     - sync handling
     - configuration
     - stream protocol programming
 **************************************************************************}

{**************************************************************************
  Stream Creation
 **************************************************************************}

function SpiAssociate ( stream: hStream; ID: hID; pac: pACB ): uLong;

function SpiEnumerateHandlers ( Hand: PHand; // ptr to array handler name/class
                                NumHand: PuLong ): uLong;

function SpiGetHandler ( HName: pChar; var phidSrc,phidTgt: hID ): uLong;

function SpiCreateStream ( hidSrc: hID;        // input
                           hidTgt: hID;        // input
                           Key: pspcbkey;      // input
                           Src: PDCB;          // input - Src device info
                           Tgt: PDCB;              // input - Tgt device info
                           Evcb: PIMPL_EVCB;       // input
                           EventEntry: PEVFN;      // input
                           StreamBuf: HSTREAM;     // input
                           Stream: PHSTREAM;       // output
                           Event: PhEvent): uLong; // output - implicit hevent

function SpiSendMsg ( Stream: hStream; ID: hID; MsgType: uLong; Msg: pVoid): uLong;

// The first thing in the pMsg must be the length of the structure!
type
  Msg_Common = record
    ulMsgLen  : uLong;              // length of structure
  end;

//**************************************************************************
// Stream Control
//**************************************************************************

function SpiDestroyStream ( Stream: hStream ): uLong;
function SpiGetTime ( Stream: hStream; Time: pMMTime ): uLong;
function SpiSeekStream ( Stream: hStream; Flags: uLong; SeekPoint: Long ): uLong;

const
  // SpiSeekStream() Flags defines
  SPI_SEEK_ABSOLUTE             = $0000;         // Seek from beginning of stream
  SPI_SEEK_RELATIVE             = $0001;         // Seek from current location
  SPI_SEEK_FROMEND              = $0002;         // TEMP
  SPI_SEEK_SLAVES               = $0010;         // Seek all slave streams

  SPI_SEEK_MMTIME               = $0000;         // lSeekPoint == mmtime (default)
  SPI_SEEK_BYTES                = $0100;         // lSeekPoint == bytes

  SPI_SEEK_IFRAME               = $1000;         // Seek to nearest IFRAME

  VALIDSEEKFLAGS                = SPI_SEEK_RELATIVE OR
                                  SPI_SEEK_ABSOLUTE OR
                                  SPI_SEEK_FROMEND  OR
                                  SPI_SEEK_MMTIME OR
                                  SPI_SEEK_SLAVES OR
                                  SPI_SEEK_IFRAME OR
                                  SPI_SEEK_BYTES;

function SpiStartStream ( Stream: hStream; Flags: uLong ): uLong;

const
  // SpiStartStream() Flags defines
  SPI_START_STREAM              = $0000;         // Only start this one stream
  SPI_START_SLAVES              = $0001;         // Start this master and any slaves
  SPI_START_PREROLL             = $0002;         // Start the stream, but do preroll

  VALIDSTARTFLAGS               = SPI_START_STREAM OR
                                  SPI_START_SLAVES OR
                                  SPI_START_PREROLL;


function SpiStopStream ( Stream: hStream; Flags: uLong ): uLong;

const
  // SpiStopStream() Flags defines
  SPI_STOP_STREAM               = $0000;   // Only stop this one stream
                                           // The default is to pause the data
                                           //  stream. No change to data buffers.
                                           //  synchronous call (no event notification)
  SPI_STOP_SLAVES               = $0001;   // Stop this master and any slaves
  SPI_STOP_FLUSH                = $0002;   // Stop and flush all filled buffers.
                                           //  Stops the Src & Tgt SH, lets the
                                           //  Tgt SH run until out of buffers
                                           //  thereby, "flushing" all buffers.
                                           //  Tgt SH stops when out of buffers
                                           //  (This is a ASYNCHRONOUS call, event
                                           //   notification sent to appl when done.)
  SPI_STOP_DISCARD              = $0004;   // Stop and discard all filled buffers.
                                           //  Stops the Src & Tgt SH
                                           //  then discards all buffers current for
                                           //  this stream.
                                           //  (This is a ASYNCHRONOUS call, event
                                           //   notification sent to appl when done.)

  VALIDSTOPFLAGS                = SPI_STOP_STREAM OR
                                  SPI_STOP_SLAVES OR
                                  SPI_STOP_FLUSH OR
                                  SPI_STOP_DISCARD;

//**************************************************************************
// Event Handling
//**************************************************************************

function SpiDisableEvent ( Event: hEvent ): uLong;
function SpiEnableEvent ( ev: pEvcb; Event: phEvent ): uLong;

//**************************************************************************
// Sync Handling
//**************************************************************************


function SpiDisableSync  ( MasterStream: hStream ): uLong;
function SpiEnableSync ( MasterStream: hStream; SlaveList: pSlave;
  NumSlaves: uLong; TimeSync: mmTime ): uLong;
function SpiDetermineSyncMaster ( MasterStream: hStream; MasterList: pMaster;
  NumMasters: uLong ): uLong;

//**************************************************************************
// Protocol manipulation
//**************************************************************************

function SpiGetProtocol ( ID: hID; InKey: pspcbkey; OutKey: pspcb ): uLong;
function SpiInstallProtocol ( ID: hID; InKey: pspcbkey; InSpcb: pspcb;
  Flags: uLong ): uLong;

const
  // SpiInstallProtocol() Flags defines
  SPI_INSTALL_PROTOCOL          = $0000;         // Install this protocol
  SPI_DEINSTALL_PROTOCOL        = $0001;         // DeInstall this protocol

  VALIDINSTALLFLAGS             = SPI_INSTALL_PROTOCOL OR SPI_DEINSTALL_PROTOCOL;

function SpiEnumerateProtocols ( ID: hID;
                                 SPCBKeys: Pointer;            // ptr to buffer to fill with SPCB keys
                                 NumSPCBKeys: pUlong ): uLong; // # of entries buffer on input,
                                                               // # of SPCB key on output.

//**************************************************************************
//
//  Function Prototypes for SMH functions
//  All use Pure C calling convention
// NOTE ABOUT POINTERS:
//  0:32 linear addresses for ring 3 (DLL) stream handlers
//  16:16 selector/offset addresses for ring 0 (PDD) stream handlers
//**************************************************************************

type
  SMHEntryPoint = function( pParmIn: Pointer ): uLong;
  smh_Common = record             // smhfunc
    uFunction : uLong;            // SMH command function
    ID: hID;                      // handler ID
  end;
  psmh_Common = ^smh_Common;

const
  smh_Register                  = 0;           // (Valid only from ring 3 stream
                                               //  handler)
type
  Parm_Reg = record                            // smhreg
    ulFunction: uLong;                         // SMH command function
    pszSHName: pChar;                          // Max size = 8 characters
    phidSrc: ^hID;                             // (9 including null)
    phidTgt: ^hID;
    pshcfnEntry: PSHCFN;                       // Handler entry point for SHC's
                                               //  Only used for Ring 0 handlers.
    ulFlags: uLong;
    ulMaxNumStreams: uLong;                    // Max # of streams
    ulMaxNumEvents: uLong;                     // Max # of events/stream
  end;
  pParm_Reg = ^Parm_Reg;

const
  REGISTER_TGT_HNDLR            = $0001;         // This handler is Target.
  REGISTER_SRC_HNDLR            = $0002;         // This handler is Source.
                                                 // Handler can be both.
  REGISTER_NONSTREAMING         = $0004;         // Handler is non-streaming.
  VALIDREGISTERFLAGS            = REGISTER_TGT_HNDLR OR REGISTER_SRC_HNDLR OR REGISTER_NONSTREAMING;

// Notes:
//  - Since ring 0 (DD) stream handlers can not use the IDC interface to the
//    sync/stream manager during DD initialization time, it must use the IOCTL
//    function to perform the SMH_REGISTER function. The addresses are 16:16
//    for this IOCTl instead of 0:32, because it comes form a device driver.
  SSMDD_CATEGORY                = $0081;    // Category (For ring 0 stream handler)
  IOCTL_FUNC_SMH_REGISTER       = $0040;    // Function (For ring 0 stream handler)


//**************************************************************************
  SMH_DEREGISTER                = 1;           // SMH_Deregister()

type
  Parm_DeReg = record                          // smhder
    uFunction : uLong;                         // SMH command function
    pszSHName : pChar;                         // Max size = 8 char, 9 includes
  end;
  pParm_DeReg = ^Parm_DeReg;

//**************************************************************************
const
  SMH_REPORTEVENT               = 2;           // SMH_ReportEvent()

type
  Parm_Event = record                          // smhrev
    ulFunction : uLong;                        // SMH command function
    ID         : hID;
    Event      : HEvent;                       // Used only for explicit events
                                               //  Must be 0 for sync and implicit
                                               //  events (i.e. error events)
    pevcbEvent: PEVCB;                         // Event status & HSTREAM
  end;
  pParm_Event = ^Parm_Event;

//**************************************************************************
const
  SMH_NOTIFY                    = 3;           // SMH_Notify()

type
  Parm_Notify = record                         // smhnot
    ulFunction      : uLong;                   // Input - SMH command function
    hid             : hID;                     // Input
    hstream         : hStream;                 // Input
    ulFlags         : uLong;                   // Input/Output
    ulGetNumEntries : uLong;                   // Input/Output - # of entries in table
    ulRetNumEntries : uLong;                   // Input/Output - # of entries in table
    pGetBufTab      : pVoid;                   // Output - Ptr to buffer/record table
    pRetBufTab      : pVoid;                   // Input - Ptr to buffer/record table
  end;
  pParm_Notify = ^Parm_Notify;

  SrcBufTab = record                           // srcbuftab
    pBuffer       : pVoid;                     // Ptr to buffer
    pRecord       : pVoid;                     // Ptr to record in buffer (split-streams only)
    ulLength      : uLong;                     // Max buf length on GetEmpty, Filled
                                               // (actual) rec/buf length on ReturnFull.
    ulMessageParm : uLong;                     // Message to passed to application
    mmtimeOffset  : mmTime;                    // mmtime offset from beginning of buffer
  end;
  pSrcBufTab = ^SrcBufTab;

  TgtBufTab = record                           // tgtbuftab
    pBuffer       : pVoid;                     // Ptr to buffer
    ulBufId       : uLong;                     // Buffer ID. Passed to SH on GetFull, must
                                               // be passed back to SSM on ReturnEmpty.
    ulLength      : uLong;                     // Filled (actual) buffer length on GetFull,
                                               // unused on ReturnEmpty.
    ulMessageParm : uLong;                     // Message to passed to application
    mmtimeOffset  : mmTime;                    // mmtime offset from beginning of buffer
  end;
  pTgtBufTab = ^TgtBufTab;

// EXTENDED SMH_NOTIFY Structures

  Parm_Enotify = record                        // smhenot
    ulFunction      : uLong;                   // Input - SMH command function
    hid             : hID;                     // Input
    hstream         : hStream;                 // Input
    ulFlags         : uLong;                   // Input/Output
    ulGetNumEntries : uLong;                   // Input/Output - # of entries in table
    ulRetNumEntries : uLong;                   // Input/Output - # of entries in table
    pGetBufTab      : pVoid;                   // Output - Ptr to buffer/record table
    pRetBufTab      : pVoid;                   // Input - Ptr to buffer/record table
    ulParm1         : uLong;                   // Reserved for future use
    ulParm2         : uLong;                   // Reserved for future use
  end;
  pParm_Enotify = ^Parm_Enotify;

  ESrcBufTab = record                          // esrcbuftab
    pBuffer       : pVoid;                     // Ptr to buffer
    pRecord       : pVoid;                     // Ptr to record in buffer (split-streams only)
    ulLength      : uLong;                     // Max buf length on GetEmpty, Filled
                                               // (actual) rec/buf length on ReturnFull.
    ulMessageParm : uLong;                     // Message to passed to application
    mmtimeOffset  : mmTime;                    // mmtime offset from beginning of buffer
    ulParm1       : uLong;                     // Record or buffer specific data
    ulParm2       : uLong;                     // Record or buffer specific data
  end;
  pESrcBufTab = ^ESrcBufTab;

  ETgtBufTab = record                          // etgtbuftab
    pBuffer         : pVoid;                   // Ptr to buffer
    ulBufId         : uLong;                   // Buffer ID. Passed to SH on GetFull, must
                                               // be passed back to SSM on ReturnEmpty.
    ulLength        : uLong;                   // Filled (actual) buffer length on GetFull,
                                               // unused on ReturnEmpty.
    ulMessageParm   : uLong;                   // Message to passed to application
    mmtimeOffset    : mmTime;                  // mmtime offset from beginning of buffer
    ulParm1         : uLong;                   // Buffer specific data
    ulParm2         : uLong;                   // Buffer specific data
  end;
  pETgtBufTab = ^ETgtBufTab;

  EPSrcBufTab = record                         // epsrcbuftab
    pBuffer        : pVoid;                    // Ptr to buffer
    pRecord        : pVoid;                    // Ptr to record in buffer (split-streams only)
    ulLength       : uLong;                    // Max buf length on GetEmpty, Filled
                                               // (actual) rec/buf length on ReturnFull.
    ulMessageParm  : uLong;                    // Message to passed to application
    mmtimeOffset   : mmTime;                   // mmtime offset from beginning of buffer
    ulParm1        : uLong;                    // Record or buffer specific data
    ulParm2        : uLong;                    // Record or buffer specific data
    pProcessLin    : pVoid;                    // Process Linear record ptr
  end;
  pEPSrcBufTab = ^EPSrcBufTab;

  EPTgtBufTab = record                         // eptgtbuftab
    pBuffer        : pVoid;                    // Ptr to buffer
    ulBufId        : uLong;                    // Buffer ID. Passed to SH on GetFull, must
                                               // be passed back to SSM on ReturnEmpty.
    ulLength       : uLong;                    // Filled (actual) buffer length on GetFull,
                                               // unused on ReturnEmpty.
    ulMessageParm  : uLong;                    // Message to passed to application
    mmtimeOffset   : mmTime;                   // mmtime offset from beginning of buffer
    ulParm1        : uLong;                    // Buffer specific data
    ulParm2        : uLong;                    // Buffer specific data
    pProcessLin    : pVoid;                    // Process Linear buffer ptr
  end;
  pEPTgtBufTab = ^EPTgtBufTab;

const
  //SMH_ulFlags
  BUF_GETEMPTY                  = $00000001;   // Ptr returned in SMH_pGetBuffer
  BUF_RETURNFULL                = $00000002;   // Ptr passed in SMH_pRetBuffer
  BUF_GETFULL                   = $00000004;   // Ptr returned in SMH_pGetBuffer
  BUF_RETURNEMPTY               = $00000008;   // Ptr passed in SMH_pRetBuffer
  BUF_GIVEBUF                   = $00000010;   // Ptr passed in SMH_pRetBuffer
  BUF_EOS                       = $00000100;   // End of stream. Source sets this on
                                               //  last buffer. Target sets it after
                                               //  consuming the laset buffer.
  BUF_RECORDS                   = $00004000;   // One or more records (Split-stream)
  BUF_LASTRECORD                = $00008000;   // (BUF_RETURNFULL only) Mark
                                               // these record(s) as being the
                                               // last in the buffer. So the SSM
                                               // knows the maximum # of records
                                               // produced for this buffer.
                                               // (Split stream only)
  //SMH_ulFlags
  BUF_LINEAR                    = $00010000;   // Ptrs are Global linear
  BUF_PHYSICAL                  = $00020000;   // Ptrs are physical
                                               // (valid only for phyically
                                               //  contiguous buffers)
  BUF_RESERVED                  = $00040000;   // Reserved
  BUF_GDT                       = $00080000;   // Ptrs are GDT sel:offset
  BUF_EXTENDED                  = $80000000;   // Use Extended SMH_NOTIFY structures
  BUF_EXTENDEDPTR               = $40000000;   // Use Extendedptr SMH_NOTIFY structures
                                               //  Implies BUF_EXTENDED

  VALIDSOURCEFLAGS              = BUF_RETURNFULL or BUF_GETEMPTY or BUF_EOS or BUF_LASTRECORD or BUF_PHYSICAL or BUF_LINEAR or BUF_GDT or BUF_RECORDS or BUF_GIVEBUF or BUF_EXTENDED or BUF_EXTENDEDPTR;
  VALIDTARGETFLAGS              = BUF_RETURNEMPTY or BUF_GETFULL or BUF_PHYSICAL or BUF_LINEAR or BUF_GDT or BUF_EOS or BUF_EXTENDED or BUF_EXTENDEDPTR;


//**************************************************************************
const
  SMH_LOCKMEM                   = 4;              // SMH_LockMem()

type
  Parm_LockM = record                             // smhloc
    ulFunction  : uLong;                          // SMH command function
    pBuffer     : pVoid;
    ulBufSize   : uLong;
    lockh       : PLockH;
    Flags       : uLong;
  end;
  pParm_LockM = ^Parm_LockM;

const
  //SMH_ulFlags
  SSM_LOCKMEM                   = $0000;         // Lock Memory.
  SSM_UNLOCKMEM                 = $0001;         // Unlock memory.
  SSM_CONTIGLOCK                = $0002;         // Lock memory contiguously.
  SSM_LOCKMEM_RESERVED1         = $0100;         // reserved
  SSM_LOCKMEM_RESERVED2         = $0200;         // reserved
//**************************************************************************

//**************************************************************************
//
//  Function Prototypes for SHC functions (Stream Handler Functions)
//  All use Pure C calling convention
//
// NOTE ABOUT POINTERS:
//  0:32 linear addresses for ring 3 (DLL) stream handlers
//  16:16 selector/offset addresses for ring 0 (PDD) stream handlers
//  Use the System.SelToFlat or System.FlatToSel to convert one to the other
//**************************************************************************
type
  shc_Common = record                          // shcfunc
    uFunction  : uLong;                        // Handler command function
    ID         : hID;                          // handler ID
  end;
  pshc_Common = ^shc_Common;

//**************************************************************************
const
  SHC_ASSOCIATE                 = 0;

type
  Parm_Assoc = record                          // shcass
    ulFunction    : uLong;                     // Handler command function
    hid           : hID;                       // handler ID
    hstream       : hStream;                   // handle of stream instance
    pacb          : PACB;                      // pointer to associate control block
  end;
  pParm_Assoc = ^Parm_Assoc;

//**************************************************************************
const
  SHC_CLOSE                     = 1;

type
  Parm_Close = record                          // shcclo
    ulFunction    : uLong;                     // Handler command function
    ID            : hID;                       // handler ID
  end;
  pParm_Close = ^Parm_Close;

//**************************************************************************
const
  SHC_CREATE                    = 2;

type
  Parm_Create = record                         // shccrt
    ulFunction   :  uLong;                     // Handler command function
    ID           :  hID;                       // handler ID
    Stream       :  hStream;                   // handle of stream instance
    spcbkey      :  SPCBKEY;                   // type of stream to create
    spcb         :  PSPCB;                     // Pointer to SPCB from handler
    hstreamBuf   :  hStream;                   // Used for split streams or to associate
                                               // another stream with this stream.
    Dcb          :  PDCB;                      // pointer to device control block
  end;
  pParm_Create = ^Parm_Create;

//**************************************************************************
const
  SHC_DESTROY                   = 3;

type
  Parm_Destroy = record                        // shcdes
    ulFunction    : uLong;                     // Handler command function
    ID            : hID;                       // handler ID
    Stream        : hStream;                   // handle of stream instance
  end;
  pParm_Destroy = ^Parm_Destroy;

//**************************************************************************
const
  SHC_START                     = 4;

type
  Parm_Start = record                          // shcstr
    ulFunction    : uLong;                     // Handler command function
    ID            : hID;                       // handler ID
    Stream        : hStream;                   // handle of stream instance
    Flags         : uLong;                     // Start flags
  end;
  pParm_Start = ^Parm_Start;

const
  // Flags
  FLUSH_START                   = $0001;       // This start is a result of a Flush Stop command.

//**************************************************************************
const
  SHC_STOP                      = 5;

type
  Parm_Stop = record                           // shcstp
    ulFunction    : uLong;                     // Handler command function
    ID            : hID;                       // handler ID
    Stream        : hStream;                   // handle of stream instance
    Flags         : uLong;                     // Stop flags (refer to Flags defines under
                                               //  SpiStopStream() call.
  end;
  pParm_Stop = ^Parm_Stop;

//**************************************************************************
const
  SHC_SEEK                      = 6;

type
  Parm_Seek = record                           // shcsek
    ulFunction    : uLong;                     // Handler command function
    ID            : hID;                       // handler ID
    Stream        : hStream;                   // handle of stream instance
    Flags         : uLong;                     // Seek flag (refer to Flags defines under
                                               //  SpiSeekStream() call.
    SeekPoint     : Long;                      // seek to point , mmtime or other
  end;
  pParm_Seek = ^Parm_Seek;

//**************************************************************************
const
  SHC_ENABLE_EVENT              = 7;

type
  Parm_EnEvent = record                        // shceev
    ulFunction    : uLong;                     // Handler command function
    ID            : hID;                       // handler ID
    Event         : hEvent;                    // handle of event to enable
    evcbUser      : PEvcb;                     // User event information (e.g. hstream
                                               //  EventType, EventSubType)
  end;
  pParm_EnEvent = ^Parm_EnEvent;

//**************************************************************************
const
  SHC_DISABLE_EVENT             = 8;

type
  Parm_DisEvent = record                       // shcdev
    ulFunction    : uLong;                     // Handler command function
    ID            : hID;                       // handler ID
    Stream        : hStream;                   // handle of stream for this event
    Event         : hEvent;                    // handle of event to disable
  end;
  pParm_DisEvent = ^Parm_DisEvent;

//**************************************************************************
const
  SHC_ENABLE_SYNC               = 9;

type
  Parm_EnSync = record                         // shcesy
    ulFunction    : uLong;                     // Handler command function
    ID            : hID;                       // handler ID
    Stream        : hStream;                   // handle of stream instance
    Flags         : uLong;                     // Sync flags
    TimeSync      : mmTime;                    // granularity of sync interval (if null, use default)
    SyncPulse     : PSync_EVCB;                // Sync pulse EVCB information
    PulseSem      : uLong;                     // Optional 16 bit system
                                               // Semaphore for handler
  end;
  pParm_EnSync = ^Parm_EnSync;

const
  // Flags
  SYNC_MASTER                   = $0000;    // The handler will be a master for this sync
  SYNC_SLAVE                    = $0001;    // The handler will be a slave for this sync

//**************************************************************************
const
  SHC_DISABLE_SYNC              = 10;

type
  Parm_DisSync = record                        // shcdsy
    ulFunction    : uLong;                     // Handler command function
    ID            : hID;                       // handler ID
    Stream        : hStream;                   // handle of stream instance
  end;
  pParm_DisSync = ^Parm_DisSync;

//**************************************************************************
const
  SHC_GET_TIME                  = 11;

type
  Parm_gTime = record                          // shcgti
    ulFunction    : uLong;                     // Handler command function
    ID            : hID;                       // handler ID
    Stream        : hStream;                   // handle of stream instance
    TimeCurrent   : mmTime;                    // Returns current stream time
  end;
  pParm_gTime = ^Parm_gTime;

//**************************************************************************
const
  SHC_GET_PROTOCOL              = 12;

type
  Parm_gProt = record                          // shcgpt
    ulFunction   :  uLong;                     // Handler command function
    ID           :  hID;                       // handler ID
    spcbkey      :  SPCBKEY;                   // Key of SPCB
    spcb         :  PSPCB;                     // Pointer to SPCB (output)
  end;
  pParm_gProt = ^Parm_gProt;

//**************************************************************************
const
  SHC_INSTALL_PROTOCOL          = 13;

type
  Parm_InstProt = record                       // shcipt
    ulFunction   :  uLong;                     // Handler command function
    ID           :  hID;                       // handler ID
    spcbkey      :  SPCBKEY;                   // Key of SPCB
    spcb         :  PSPCB;                     // Pointer to SPCB to install
    Flags        :  uLong;                     // Install / Deinstall flags
  end;
  pParm_InstProt = ^Parm_InstProt;

//**************************************************************************
const
  SHC_ENUMERATE_PROTOCOLS       = 14;

type
  Parm_EnumProt = record                       // shcqpi
    ulFunction   :  uLong;                     // Handler command function
    ID           :  hID;                       // handler ID
    SPCBKeys     :  Pointer;                   // ptr to buffer to fill with SPCB keys
    NumSPCBKeys  :  pUlong;                    // # of entries buffer on input,
                                               //  # of SPCB key on output.
  end;
  pParm_EnumProt = ^Parm_EnumProt;

//**************************************************************************
const
  SHC_NEGOTIATE_RESULT          = 15;

type
  Parm_Negotiate = record                      // shcneg
    ulFunction   :  uLong;                     // Handler command function
    ID           :  hID;                       // handler ID
    Stream       :  hStream;                   // handle of stream instance
    SPCB         :  pSPCB;                     // Ptr to negotiated SPCB
    ErrorStatus  :  uLong;                     // On error, indicates which field in the
  end;
  pParm_Negotiate = ^Parm_Negotiate;

//**************************************************************************
const
  SHC_SENDMSG                   = 16;

type
  Parm_SndMsg = record                         // shcsndmsg
    ulFunction   :  uLong;                     // Handler command function
    ID           :  hID;                       // handler ID
    Stream       :  hStream;                   // handle of stream instance
    MsgType      :  uLong;                     // Stream handler message type
    Msg          :  Pointer;                   // Pointer to Message control block
  end;
  pParm_SndMsg = ^Parm_SndMsg;

//**************************************************************************

{----[ MCIOS2 ]----}

const
  MCI_TRUE                      = 1;
  MCI_FALSE                     = 0;

  // MCI command messages identifiers
  MCI_OPEN                      = 1;
  MCI_CLOSE                     = 2;
  MCI_ESCAPE                    = 3;
  MCI_PLAY                      = 4;
  MCI_SEEK                      = 5;
  MCI_STOP                      = 6;
  MCI_PAUSE                     = 7;
  MCI_INFO                      = 8;
  MCI_GETDEVCAPS                = 9;
  MCI_STATUS                    = 10;
  MCI_SPIN                      = 11;
  MCI_SET                       = 12;
  MCI_STEP                      = 13;
  MCI_RECORD                    = 14;
  MCI_SYSINFO                   = 15;
  MCI_SAVE                      = 16;
  MCI_CUE                       = 17;
  MCI_UPDATE                    = 18;
  MCI_SET_CUEPOINT              = 19;
  MCI_SET_POSITION_ADVISE       = 20;
  MCI_SET_SYNC_OFFSET           = 21;
  MCI_LOAD                      = 22;
  MCI_ACQUIREDEVICE             = 23;
  MCI_RELEASEDEVICE             = 24;
  MCI_MASTERAUDIO               = 25;
  MCI_GETTOC                    = 26;
  MCI_DEVICESETTINGS            = 27;
  MCI_CONNECTOR                 = 28;
  MCI_RESUME                    = 29;
  MCI_CONNECTORINFO             = 31;
  MCI_DEFAULT_CONNECTION        = 32;
  MCI_CONNECTION                = 33;
  MCI_GROUP                     = 34;
  MCI_CAPTURE                   = 40;
  MCI_FREEZE                    = 41;
  MCI_GETIMAGEBUFFER            = 42;
  MCI_GETIMAGEPALETTE           = 43;
  MCI_PUT                       = 44;
  MCI_REALIZE                   = 45;
  MCI_REWIND                    = 46;
  MCI_RESTORE                   = 47;
  MCI_SETIMAGEBUFFER            = 48;
  MCI_SETIMAGEPALETTE           = 49;
  MCI_UNFREEZE                  = 50;
  MCI_WHERE                     = 51;
  MCI_WINDOW                    = 52;
  MCI_DELETE                    = 53;
  MCI_CUT                       = 54;
  MCI_PASTE                     = 55;
  MCI_COPY                      = 56;
  MCI_REDO                      = 57;
  MCI_UNDO                      = 58;
  MCI_MIXNOTIFY                 = 59;
  MCI_SETTUNER                  = 60;
  MCI_MAX_COMMAND               = 60;
  MCI_USER_MESSAGES             = 2000;

type
  RECT = uLong;
  HDCT = uLong;

const
  // Special device ID for 'all'
  MCI_ALL_DEVICE_ID             = $FFFF;

  // MCI implementation limits
  MAX_DEVICE_NAME               = 20;
  MAX_ALIAS_NAME                = 20;
  MAX_PRODINFO                  = 40;
  MAX_EXTENSION_NAME            = 4;
  MAX_DEV_PARAMS                = 128;
  MAX_VERSION_NUMBER            = 6;
  MAX_PDD_NAME                  = 9;
  MAX_DLL_NAME                  = 260;
  MAX_CLASSES                   = 10;
  MAX_CONNECTORS                = 10;
  MAX_EXTENSIONS                = 25;
  MAX_TYPEBUFFER                = 256;

  // MCI Device Type Constants
  MCI_DEVTYPE_VIDEOTAPE         = 1;
  MCI_DEVTYPE_VIDEODISC         = 2;
  MCI_DEVTYPE_CD_AUDIO          = 3;
  MCI_DEVTYPE_DAT               = 4;
  MCI_DEVTYPE_AUDIO_TAPE        = 5;
  MCI_DEVTYPE_OTHER             = 6;
  MCI_DEVTYPE_WAVEFORM_AUDIO    = 7;
  MCI_DEVTYPE_SEQUENCER         = 8;
  MCI_DEVTYPE_AUDIO_AMPMIX      = 9;
  MCI_DEVTYPE_OVERLAY           = 10;
  MCI_DEVTYPE_ANIMATION         = 11;
  MCI_DEVTYPE_DIGITAL_VIDEO     = 12;
  MCI_DEVTYPE_SPEAKER           = 13;
  MCI_DEVTYPE_HEADPHONE         = 14;
  MCI_DEVTYPE_MICROPHONE        = 15;
  MCI_DEVTYPE_MONITOR           = 16;
  MCI_DEVTYPE_CDXA              = 17;

  // MCI Device Type Names
  MCI_DEVTYPE_VIDEOTAPE_NAME    = 'Videotape';
  MCI_DEVTYPE_VIDEODISC_NAME    = 'Videodisc';
  MCI_DEVTYPE_CD_AUDIO_NAME     = 'CDaudio';
  MCI_DEVTYPE_DAT_NAME          = 'DAT';
  MCI_DEVTYPE_AUDIO_TAPE_NAME   = 'Audiotape';
  MCI_DEVTYPE_OTHER_NAME        = 'Other';
  MCI_DEVTYPE_WAVEFORM_AUDIO_NAME = 'Waveaudio';
  MCI_DEVTYPE_SEQUENCER_NAME    = 'Sequencer';
  MCI_DEVTYPE_AUDIO_AMPMIX_NAME = 'Ampmix';
  MCI_DEVTYPE_OVERLAY_NAME      = 'Overlay';
  MCI_DEVTYPE_ANIMATION_NAME    = 'Animation';
  MCI_DEVTYPE_DIGITAL_VIDEO_NAME= 'Digitalvideo';
  MCI_DEVTYPE_SPEAKER_NAME      = 'Speaker';
  MCI_DEVTYPE_HEADPHONE_NAME    = 'Headphone';
  MCI_DEVTYPE_MICROPHONE_NAME   = 'Microphone';
  MCI_DEVTYPE_MONITOR_NAME      = 'Monitor';
  MCI_DEVTYPE_CDXA_NAME         = 'CDXA';

  MCI_MAX_SYSTEM_DEVICE_NAMES   = 17;

  // GetDevCaps, set, and status item base values
  MCI_AMP_ITEM_BASE             = $1000;
  MCI_CD_ITEM_BASE              = $2000;
  MCI_CDXA_ITEM_BASE            = $3000;
  MCI_VD_ITEM_BASE              = $4000;
  MCI_SEQ_ITEM_BASE             = $5000;
  MCI_WAVE_ITEM_BASE            = $6000;
  MCI_VID_ITEM_BASE             = $7000;
  MCI_DGV_ITEM_BASE             = $8000;
  MCI_OVLY_ITEM_BASE            = $9000;

  // Flags for mciDriverNotify
  MCI_NOTIFY_SUCCESSFUL         = $0000;
  MCI_NOTIFY_SUPERSEDED         = $0001;
  MCI_NOTIFY_ABORTED            = $0002;
  MCI_NOTIFY_ERROR              = $0003;

  // mciDriverNotify Message Types
  MM_MCINOTIFY                  = $0500;
  MM_MCIPASSDEVICE              = $0501;
  MM_MCIPOSITIONCHANGE          = $0502;
  MM_MCICUEPOINT                = $0503;
  MM_MCIPLAYLISTMESSAGE         = $0504;
  MM_MCIEVENT                   = $0505;
  MM_MCISYNCH                   = $0506;

  MCI_LOSING_USE                = $00000001;
  MCI_GAINING_USE               = $00000002;

  // Common message flags. $00000$x are reserved for common flags.
  MCI_NOTIFY                    = $00000001;
  MCI_WAIT                      = $00000002;
  MCI_FROM                      = $00000004;
  MCI_TO                        = $00000008;
  MCI_MILLISECONDS              = $00000010;
  MCI_TRACK                     = $00000020;
  MCI_OVER                      = $00000040;
  MCI_TEST                      = $00000080;
  MCI_TO_BUFFER                 = $00000100;
  MCI_FROM_BUFFER               = $00000200;
  MCI_CONVERT_FORMAT            = $00000400;

  // Time formats
  MCI_FORMAT_MILLISECONDS       = $00000001;
  MCI_FORMAT_mmTime             = $00000002;
  MCI_FORMAT_MSF                = $00000005;
  MCI_FORMAT_TMSF               = $00000006;
  MCI_FORMAT_CHAPTERS           = $00000007;
  MCI_FORMAT_FRAMES             = $00000008;
  MCI_FORMAT_HMS                = $00000009;
  MCI_FORMAT_TRACKS             = $0000000A;
  MCI_FORMAT_BYTES              = $0000000B;
  MCI_FORMAT_SAMPLES            = $0000000C;
  MCI_FORMAT_HMSF               = $0000000D;
  MCI_FORMAT_SET_SMPTE_24       = $0000000E;
  MCI_FORMAT_SET_SMPTE_25       = $0000000F;
  MCI_FORMAT_SET_SMPTE_30       = $00000010;
  MCI_FORMAT_SET_SMPTE_30DROP   = $00000011;
  MCI_FORMAT_SET_SONGPTR        = $00000012;
  MCI_FORMAT_uSec               = $00000013;

  // Speed formats
  MCI_FORMAT_PERCENTAGE         = $00000003;
  MCI_FORMAT_FPS                = $00000004;

// Time format conversion macros
function mSecToMM(Value: Cardinal): mmTime; inline;
begin
  If Value > $FFFFFFFF div 3 then
    Result := 0
  else
    Result := Value div 3;
end;

function mSecFromMM(Value: mmTime): uLong; inline;
begin
  Result := (Value+1) div 3;
end;

function RedBookToMM(Value: Cardinal): mmTime; inline;
begin
  Result := ( Value and $0000FF ) * 60 * 3000 +
            ( Value and $00FF00 ) * $100 * 3000 +
            ( Value and $FF0000 ) * $10000 * 3000 div 75;

end;

function fps24ToMM(Value: Cardinal): mmTime; inline;
begin
  Result := ( Value and $000000FF ) * 60 * 60 * 3000 +
            ( Value and $0000FF00 ) * $100 * 60 * 3000 +
            ( Value and $00FF0000 ) * $10000 * 3000 +
            ( Value and $FF000000 ) * $10000 * 3000 div 24;
end;

function fps25ToMM(Value: Cardinal): mmTime; inline;
begin
  Result := ( Value and $000000FF ) * 60 * 60 * 3000 +
            ( Value and $0000FF00 ) * $100 * 60 * 3000 +
            ( Value and $00FF0000 ) * $10000 * 3000 +
            ( Value and $FF000000 ) * $10000 * 3000 div 25;
end;

function fps30ToMM(Value: Cardinal): mmTime; inline;
begin
  Result := ( Value and $000000FF ) * 60 * 60 * 3000 +
            ( Value and $0000FF00 ) * $100 * 60 * 3000 +
            ( Value and $00FF0000 ) * $10000 * 3000 +
            ( Value and $FF000000 ) * $10000 * 3000 div 30;
end;

function HMSToMM(Value: Cardinal): mmTime; inline;
begin
  Result := ( Value and $0000FF ) * 60 * 60 * 3000 +
            ( Value and $00FF00 ) * $100 * 60 * 3000 +
            ( Value and $FF0000 ) * $10000 * 3000;

end;

// The +20 is used for rounding purposes.  It is derived by:
// 1/2 * ((300 MMTIME/SEC / (75 FRAMES/SEC)) = 20 MMTIME/HALF-FRAME
function RedBookFromMM(Value: mmTime): Cardinal; inline;
begin
  if Value+20 >= $100*60*3000 then
    Result := 0
  else
    Result := (Value+20) div (60*3000) +
              ((Value+20) mod ((60*3000) div 3000)) shl 8 +
              ((Value+20) div ((3000 div 75) mod 75)) shl 16;
end;

function FPS24FromMM(Value: mmTime): Cardinal; inline;
begin
  if Value+63 >= $A4CB8000 then // $100*60*60*3000 then
    Result := 0
  else
    Result := ((((Value+63) mod 3000) div (3000 div 24)) shl 24) and $FF000000 +
              ((((Value+63) div 3000) mod 60) shl 16) and $00FF0000 +
              (((((Value+63) div 3000) div 60) mod 60) shl 8) and $0000FF00 +
              ((((Value+63) div 3000) div 60) div 60) and $000000FF;
end;

function FPS25FromMM(value: mmTime): Cardinal; inline;
begin
  if Value+60 >= $A4CB8000 then // $100*60*60*3000
    Result := 0
  else
    Result := ((((Value+60) mod 3000) div (3000 div 25)) shl 24) and $FF000000 +
              ((((Value+60) div 3000) mod 60) shl 16) and $00FF0000 +
              (((((Value+60) div 3000) div 60) mod 60) shl 8) and $0000FF00 +
              ((((Value+60) div 3000) div 60) div 60) and $000000FF;
end;

function FPS30FromMM(value: mmTime): Cardinal; inline;
begin
  if Value+50 >= $A4CB8000 then // $100*60*60*3000
    Result := 0
  else
    Result := ((((Value+50) mod 3000) div (3000 div 30)) shl 24) and $FF000000 +
              ((((Value+50) div 3000) mod 60) shl 16) and $00FF0000 +
              (((((Value+50) div 3000) div 60) mod 60) shl 8) and $0000FF00 +
              ((((Value+50) div 3000) div 60) div 60) and $000000FF;
end;

function HMSFromMM(value: mmTime): Cardinal; inline;
begin
  if Value+50 >= $A4CB8000 then // $100*60*60*3000
    Result := 0
  else
    Result := (((( Value+50) div 3000) mod 60) shl 16) and $00FF0000 +
              (((((Value+50) div 3000) div 60) mod 60) shl 8) and $0000FF00 +
              (((( Value+50) div 3000) div 60) div 60) and $000000FF;
end;

function tmsf_track(time: mmTime): Byte; inline;
begin
  Result := byte(time);
end;

function tmsf_minute(time: mmTime): Byte; inline;
begin
  Result := pbyte(pchar(@time)+1)^;
end;

function tmsf_second(time: mmTime): Byte; inline;
begin
  Result := pbyte(pchar(@time)+2)^;
end;

function tmsf_frame(time: mmTime): Byte; inline;
begin
  Result := pbyte(pchar(@time)+3)^;
end;

function msf_minute(time: mmTime): Byte; inline;
begin
  Result := byte(time);
end;

function msf_second(time: mmTime): Byte; inline;
begin
  Result := pbyte(pchar(@time)+1)^;
end;

function msf_frame(time: mmTime): Byte; inline;
begin
  Result := pbyte(pchar(@time)+2)^;
end;

// Byte access with dWord macros
function uLong_lwlb(var ul): Byte; inline;  // Low word low byte
begin
  Result := uLong(ul);
end;

function uLong_lwhb(var ul): Byte; inline;  // Low word high byte
begin
  Result := pbyte(pchar(@ul)+1)^;
end;

function uLong_hwlb(var ul): Byte; inline;  // High word low byte
begin
  Result := pbyte(pchar(@ul)+2)^;
end;
function uLong_hwhb(var ul): Byte; inline;  // High word high byte
begin
  Result := pbyte(pchar(@ul)+3)^;
end;

function uLong_lowd(var ul): SmallWord; inline;  // Low word
begin
  Result := pSmallWord(pchar(@ul))^;
end;

function uLong_hiwd(var ul): SmallWord; inline;  // High word
begin
  Result := pSmallWord(pchar(@ul)+Sizeof(SmallWord))^;
end;

// Parameters for default command messages with empty parameter lists
type
  mci_Generic_Parms = record
    hwndCallback : hwnd;
  end;
  pmci_Generic_Parms = ^mci_Generic_Parms;

const
  // Flags for the MCI_ACQUIREDEVICE message
  //     $0000$00 are reserved for MCI_ACQUIREDEVICE flags
  MCI_EXCLUSIVE                 = $00000100;
  MCI_EXCLUSIVE_INSTANCE        = $00000200;
  MCI_ACQUIRE_QUEUE             = $00000400;

  // flags for the MCI_CAPTURE message
  //   $000$X00 are reserved for MCI_CAPTURE flags
  //   MCI_CONVERT is used by MCI_GETIMAGEBUFFER, MCI_SETIMAGEBUFFER
  //                          MCI_CAPTURE, and MCI_RESTORE
  MCI_CAPTURE_RECT              = $00000100;
  MCI_CONVERT                   = $00001000;

type
  // Parameter structure for the MCI_CAPTURE message
  mci_Capture_Parms = record
    hwndCallback : hwnd;
    Rect         : RectL;
  end;
  pmci_Capture_Parms = ^mci_Capture_Parms;

const
  // Flags for MCI_CONNECTOR and MCI_CONNECTION messages
  MCI_ENABLE_CONNECTOR          = $00000100;
  MCI_DISABLE_CONNECTOR         = $00000200;
  MCI_QUERY_CONNECTOR_STATUS    = $00000400;
  MCI_CONNECTOR_TYPE            = $00000800;
  MCI_CONNECTOR_INDEX           = $00001000;
  MCI_TO_CONNECTOR_INDEX        = $00002000;
  MCI_TO_CONNECTOR_TYPE         = $00004000;
  MCI_QUERY_CONNECTION          = $00008000;
  MCI_MAKE_CONNECTION           = $00010000;
  MCI_BREAK_CONNECTION          = $00020000;
  MCI_ENUMERATE_CONNECTORS      = $00040000;
  MCI_QUERY_CONNECTOR_TYPE      = $00080000;
  MCI_QUERY_VALID_CONNECTION    = $00100000;
  MCI_CONNECTOR_ALIAS           = $00200000;

  // Connector types
  MCI_MIDI_STREAM_CONNECTOR     = $00000001;
  MCI_CD_STREAM_CONNECTOR       = $00000002;
  MCI_WAVE_STREAM_CONNECTOR     = $00000003;
  MCI_AMP_STREAM_CONNECTOR      = $00000004;
  MCI_XA_STREAM_CONNECTOR       = $00000005;
  MCI_HEADPHONES_CONNECTOR      = $00000006;
  MCI_SPEAKERS_CONNECTOR        = $00000007;
  MCI_MICROPHONE_CONNECTOR      = $00000008;
  MCI_LINE_IN_CONNECTOR         = $00000009;
  MCI_LINE_OUT_CONNECTOR        = $0000000a;
  MCI_VIDEO_IN_CONNECTOR        = $0000000b;
  MCI_VIDEO_OUT_CONNECTOR       = $0000000c;
  MCI_PHONE_SET_CONNECTOR       = $0000000d;
  MCI_PHONE_LINE_CONNECTOR      = $0000000e;
  MCI_AUDIO_IN_CONNECTOR        = $0000000f;
  MCI_AUDIO_OUT_CONNECTOR       = $00000010;
  MCI_UNIVERSAL_CONNECTOR       = $00000011;

type
  // Parameter structure for the MCI_CONNECTION message
  mci_Connection_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    ulConnectorType  : uLong;                  // Connector type
    ulConnectorIndex : uLong;                  // Connector index
    pszAlias         : pChar;                  // Connection device alias
    usToDeviceID     : uShort;                 // Connected to device ID
    usReserved0      : uShort;                 // Reserved field
    ulReserved1      : uLong;                  // Reserved field
    ulReserved2      : uLong;                  // Reserved field
  end;
  pmci_Connection_Parms = ^mci_Connection_Parms;

  // Parameter structure for the MCI_CONNECTOR message
  mci_Connector_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    ulReturn         : uLong;                  // Return information
    ulConnectorType  : uLong;                  // If specified, ulConnectorIndex is relative
                                               // to the specified connector type
    ulConnectorIndex : uLong;                  // Connector number
  end;
  pmci_Connector_Parms = ^mci_Connector_Parms;

  // Parameter structure for the MCI_CONNECTORINFO message
  mci_ConnectorInfo_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    ulReturn         : uLong;                  // Return information
    ulDeviceTypeID   : uLong;                  // MCI device type
    ulConnectorType  : uLong;                  // If specified, ulConnectorIndex is relative
                                               // to the specified connector type
    ulConnectorIndex : uLong;                  // Connector number
    ulToConnectorType: uLong;                  // Connector type to test if
                                               // MCI_QUERY_VALID_CONNECTION is specified
  end;
  pmci_ConnectorInfo_Parms = ^mci_ConnectorInfo_Parms;

const
  // Flags for the MCI_CUE message
  //  $0000$00 are reserved for MCI_CUE flags
  MCI_CUE_INPUT                 = $00000100;
  MCI_CUE_OUTPUT                = $00000200;
  // Additional flags for Wave Audio for MCI_CUE
  MCI_WAVE_INPUT                = $00001000;
  MCI_WAVE_OUTPUT               = $00002000;

type
  // Parameter structure for the MCI_DEFAULT_CONNECTION message
  mci_Default_Connection_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    pszDevice        : pChar;                  // Device name
    ulConnectorType  : uLong;                  // If specified, ulConnectorIndex is relative
                                               // to the specified connector type
    ulConnectorIndex : uLong;                  // Connector number
    pszToDevice      : pChar;                  // Return device name to which the connection exists
    ulToConnectorType: uLong;                  // Connector type
    ulToConnectorIndex:uLong;                  // Connector number
  end;
  pmci_Default_Connection_Parms = ^mci_Default_Connection_Parms;

  // Parameter structure for the MCI_DEVICESETTINGS message
  mci_DeviceSettings_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    hwndNotebook     : hwnd;                   // Hwhd to notebook window
    usDeviceType     : uShort;                 // Device type
    pszDeviceName    : pChar;                  // Device name
  end;
  pmci_DeviceSettings_Parms = ^mci_DeviceSettings_Parms;

  // Parameter structure for the MCI_CUT / COPY / DELETE / UNDO / etc.
  mci_Edit_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    ulStructLen      : uLong;                  // Length of the Structure
    ulFrom           : uLong;                  // Beginning Point of Range
    ulTo             : uLong;                  // ending point of range
    pBuff            : Pointer;                // user buffer
    ulBufLen         : uLong;                  // length of user buffer
    pHeader          : Pointer;                // header which describes the buffer
  end;
  pmci_Edit_Parms = ^mci_Edit_Parms;

const
  // flags and parameter structure for the MCI_ESCAPE message
  //     $0000$00 are reserved for MCI_ESCAPE flags
  mci_Escape_String             = $00000100;

type
  mci_Escape_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    pszCommand       : pChar;                  // Command to send to the device
  end;
  pmci_Escape_Parms = ^mci_Escape_Parms;

const
  // Flags for the MCI_FREEZE message
  //  $000$X00 are reserved for MCI_FREEZE flags
  MCI_OVLY_FREEZE_RECT          = $00000100;
  MCI_OVLY_FREEZE_RECT_OUTSIDE  = $00000200;

  // Flags for the MCI_GETDEVCAPS message
  //   $0$XXX00 are reserved for MCI_GETDEVCAPS flags
  MCI_GETDEVCAPS_MESSAGE        = $00000100;
  MCI_GETDEVCAPS_ITEM           = $00000200;
  MCI_GETDEVCAPS_EXTENDED       = $00000400;

  // General MCI_GETDEVCAPS item values
  MCI_GETDEVCAPS_CAN_EJECT                                                = $00000001;
  MCI_GETDEVCAPS_CAN_LOCKEJECT  = $00000002;
  MCI_GETDEVCAPS_CAN_PLAY       = $00000003;
  MCI_GETDEVCAPS_CAN_PROCESS_INTERNAL = $00000004;
  MCI_GETDEVCAPS_CAN_RECORD     = $00000005;
  MCI_GETDEVCAPS_CAN_RECORD_INSERT    = $00000006;
  MCI_GETDEVCAPS_CAN_SAVE       = $00000007;
  MCI_GETDEVCAPS_CAN_SETVOLUME  = $00000008;
  MCI_GETDEVCAPS_CAN_STREAM     = $00000009;
  MCI_GETDEVCAPS_DEVICE_TYPE    = $0000000A;
  MCI_GETDEVCAPS_HAS_AUDIO      = $0000000B;
  MCI_GETDEVCAPS_HAS_VIDEO      = $0000000C;
  MCI_GETDEVCAPS_PREROLL_TIME   = $0000000D;
  MCI_GETDEVCAPS_PREROLL_TYPE   = $0000000E;
  MCI_GETDEVCAPS_USES_FILES     = $0000000F;
  MCI_GETDEVCAPS_HAS_IMAGE      = $00000010;
  MCI_GETDEVCAPS_WAVE_FORMAT    = $00000011;

  // Return ID's for videodisc MCI_GETDEVCAPS
  MCI_VD_MEDIA_CLV=$00000001;
  MCI_VD_MEDIA_CAV=$00000002;
  MCI_VD_MEDIA_OTHER=$00000003;

  // MCI_GETDEVCAPS item values for video devices
  MCI_VID_GETDEVCAPS_CAN_STRETCH         = MCI_VID_ITEM_BASE;
  MCI_VID_GETDEVCAPS_CAN_DISTORT         = MCI_VID_ITEM_BASE+1;
  MCI_VID_GETDEVCAPS_VIDEO_X_EXTENT      = MCI_VID_ITEM_BASE+2;
  MCI_VID_GETDEVCAPS_VIDEO_Y_EXTENT      = MCI_VID_ITEM_BASE+3;
  MCI_VID_GETDEVCAPS_IMAGE_X_EXTENT      = MCI_VID_ITEM_BASE+4;
  MCI_VID_GETDEVCAPS_IMAGE_Y_EXTENT      = MCI_VID_ITEM_BASE+5;
  MCI_VID_GETDEVCAPS_MAX_WINDOWS         = MCI_VID_ITEM_BASE+6;
  MCI_VID_GETDEVCAPS_CAN_FREEZE          = MCI_VID_ITEM_BASE+7;
  MCI_VID_GETDEVCAPS_OVERLAY_GRAPHICS    = MCI_VID_ITEM_BASE+8;
  MCI_VID_GETDEVCAPS_CAN_REVERSE         = MCI_VID_ITEM_BASE+9;
  MCI_VID_GETDEVCAPS_FAST_RATE           = MCI_VID_ITEM_BASE+10;
  MCI_VID_GETDEVCAPS_SLOW_RATE           = MCI_VID_ITEM_BASE+11;
  MCI_VID_GETDEVCAPS_NORMAL_RATE         = MCI_VID_ITEM_BASE+12;
  MCI_VID_GETDEVCAPS_MINIMUM_RATE        = MCI_VID_ITEM_BASE+13;
  MCI_VID_GETDEVCAPS_MAXIMUM_RATE        = MCI_VID_ITEM_BASE+14;

  // MCI_GETDEVCAPS flag values for Videodisc
  MCI_VD_GETDEVCAPS_CLV                  = $00000400;
  MCI_VD_GETDEVCAPS_CAV                  = $00000800;

  // MCI_GETDEVCAPS item values for Videodisc
  MCI_VD_GETDEVCAPS_CAN_REVERSE          = MCI_VID_GETDEVCAPS_CAN_REVERSE;
  MCI_VD_GETDEVCAPS_FAST_RATE            = MCI_VID_GETDEVCAPS_FAST_RATE;
  MCI_VD_GETDEVCAPS_SLOW_RATE            = MCI_VID_GETDEVCAPS_SLOW_RATE;
  MCI_VD_GETDEVCAPS_NORMAL_RATE          = MCI_VID_GETDEVCAPS_NORMAL_RATE;
  MCI_VD_GETDEVCAPS_MINIMUM_RATE         = MCI_VID_GETDEVCAPS_MINIMUM_RATE;
  MCI_VD_GETDEVCAPS_MAXIMUM_RATE         = MCI_VID_GETDEVCAPS_MAXIMUM_RATE;

  // MCI_GETDEVCAPS item values for Digital Video
  MCI_DGV_GETDEVCAPS_CAN_REVERSE         = MCI_VID_GETDEVCAPS_CAN_REVERSE;
  MCI_DGV_GETDEVCAPS_CAN_STRETCH         = MCI_VID_GETDEVCAPS_CAN_STRETCH;
  MCI_DGV_GETDEVCAPS_CAN_DISTORT         = MCI_VID_GETDEVCAPS_CAN_DISTORT;
  MCI_DGV_GETDEVCAPS_FAST_RATE           = MCI_VID_GETDEVCAPS_FAST_RATE;
  MCI_DGV_GETDEVCAPS_SLOW_RATE           = MCI_VID_GETDEVCAPS_SLOW_RATE;
  MCI_DGV_GETDEVCAPS_NORMAL_RATE         = MCI_VID_GETDEVCAPS_NORMAL_RATE;
  MCI_DGV_GETDEVCAPS_MINIMUM_RATE        = MCI_VID_GETDEVCAPS_MINIMUM_RATE;
  MCI_DGV_GETDEVCAPS_MAXIMUM_RATE        = MCI_VID_GETDEVCAPS_MAXIMUM_RATE;
  MCI_DGV_GETDEVCAPS_VIDEO_X_EXTENT      = MCI_VID_GETDEVCAPS_VIDEO_X_EXTENT;
  MCI_DGV_GETDEVCAPS_VIDEO_Y_EXTENT      = MCI_VID_GETDEVCAPS_VIDEO_Y_EXTENT;
  MCI_DGV_GETDEVCAPS_IMAGE_X_EXTENT      = MCI_VID_GETDEVCAPS_IMAGE_X_EXTENT;
  MCI_DGV_GETDEVCAPS_IMAGE_Y_EXTENT      = MCI_VID_GETDEVCAPS_IMAGE_Y_EXTENT;
  MCI_DGV_GETDEVCAPS_MAX_WINDOWS         = MCI_VID_GETDEVCAPS_MAX_WINDOWS;
  MCI_DGV_GETDEVCAPS_OVERLAY_GRAPHICS    = MCI_VID_GETDEVCAPS_OVERLAY_GRAPHICS;
  MCI_DGV_GETDEVCAPS_HAS_TUNER           = MCI_DGV_ITEM_BASE;
  MCI_DGV_GETDEVCAPS_HAS_TELETEX         = MCI_DGV_ITEM_BASE+1;
  MCI_DGV_GETDEVCAPS_HAS_AFC             = MCI_DGV_ITEM_BASE+2;

  // MCI_GETDEVCAPS item values for Video Overlay
  MCI_OVLY_GETDEVCAPS_CAN_STRETCH        = MCI_VID_GETDEVCAPS_CAN_STRETCH;
  MCI_OVLY_GETDEVCAPS_CAN_DISTORT        = MCI_VID_GETDEVCAPS_CAN_DISTORT;
  MCI_OVLY_GETDEVCAPS_VIDEO_X_EXTENT     = MCI_VID_GETDEVCAPS_VIDEO_X_EXTENT;
  MCI_OVLY_GETDEVCAPS_VIDEO_Y_EXTENT     = MCI_VID_GETDEVCAPS_VIDEO_Y_EXTENT;
  MCI_OVLY_GETDEVCAPS_IMAGE_X_EXTENT     = MCI_VID_GETDEVCAPS_IMAGE_X_EXTENT;
  MCI_OVLY_GETDEVCAPS_IMAGE_Y_EXTENT     = MCI_VID_GETDEVCAPS_IMAGE_Y_EXTENT;
  MCI_OVLY_GETDEVCAPS_MAX_WINDOWS        = MCI_VID_GETDEVCAPS_MAX_WINDOWS;
  MCI_OVLY_GETDEVCAPS_CAN_FREEZE         = MCI_VID_GETDEVCAPS_CAN_FREEZE;
  MCI_OVLY_GETDEVCAPS_OVERLAY_GRAPHICS   = MCI_VID_GETDEVCAPS_OVERLAY_GRAPHICS;

  MCI_PREROLL_NOTIFIED                   = $00000001;
  MCI_PREROLL_DETERMINISTIC              = $00000002;
  MCI_PREROLL_NONE                       = $00000003;

type
  // Parameter structure for the MCI_GETDEVCAPS message
  mci_GetDevCaps_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    ulReturn         : uLong;                  // Return field
    ulItem           : uLong;                  // Item field for GETDEVCAPS item to query
    usMessage        : uShort;                 // Field to hold MCI message to query
    usReserved0      : uShort;                 // Reserved field
  end;
  pmci_GetDevCaps_Parms = ^mci_GetDevCaps_Parms;

  // Parameter structure for the MCI_WAVE_GETDEVCAPS
  mci_Wave_GetDevCaps_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    ulReturn         : uLong;                  // Return field
    ulItem           : uLong;                  // Item field for GETDEVCAPS item to query
    usMessage        : uShort;                 // Field to hold MCI message to query
    usReserved0      : uShort;                 // Reserved field
    ulLength         : uLong;                  // Length of structure in ULONGS
    ulBitsPerSample  : uLong;                  // Number of Bits per Sample
    ulFormatTag      : uLong;                  // Format Tag
    ulSamplesPerSec  : uLong;                  // Sampling Rate
    ulChannels       : uLong;                  // Number of channels
    ulFormatMode     : uLong;                  // Either MCI_RECORD or MCI_PLAY
  end;
  pmci_Wave_GetDevCaps_Parms = ^mci_Wave_GetDevCaps_Parms;

const
  // General MCI_SET item values
  MCI_SET_MONITOR                 = $00000001;
  MCI_SET_MONITOR_AUDIO           = $00000002;
  MCI_SET_MONITOR_VIDEO           = $00000003;
  MCI_SET_RECORD                  = $00000004;

  // MCI_SET flags for amp/mixer;
  MCI_AMP_SET_BALANCE             = $00100000;
  MCI_AMP_SET_PITCH               = $00200000;
  MCI_AMP_SET_TREBLE              = $00400000;
  MCI_AMP_SET_BASS                = $00800000;
  MCI_AMP_SET_GAIN                = $01000000;
  MCI_AMP_SET_ALC                 = $00000004;
  MCI_AMP_SET_AUDIO               = $00000008;
  MCI_AMP_SET_CROSSOVER           = $00000010;
  MCI_AMP_SET_LOUDNESS            = $00000020;
  MCI_AMP_SET_MUTE                = $00000040;
  MCI_AMP_SET_REVERB              = $00000080;
  MCI_AMP_SET_STEREOENHANCE       = $00000100;
  MCI_AMP_SET_CUSTOM1             = $00000200;
  MCI_AMP_SET_CUSTOM2             = $00000400;
  MCI_AMP_SET_CUSTOM3             = $00000800;
  MCI_AMP_SET_LRVOLUME            = $00001000;
  MCI_AMP_SET_MID                 = $00020000;
  MCI_AMP_SET_CHORUS              = $00004000;  // typo? 40000?
  MCI_AMP_SET_VOLUME              = $00080000;  // MCI_SET_VOLUME;
  MCI_AMP_SET_MONITOR             = MCI_SET_MONITOR_AUDIO;

  // Potential values for the ulValue field of MCI_AMP_GETDEVCAPS
  MCI_AMP_CAN_SET_MONITOR         = MCI_AMP_SET_MONITOR;
  MCI_AMP_CAN_SET_BALANCE         = MCI_AMP_SET_BALANCE;
  MCI_AMP_CAN_SET_ALC             = MCI_AMP_SET_ALC;
  MCI_AMP_CAN_SET_CROSSOVER       = MCI_AMP_SET_CROSSOVER;
  MCI_AMP_CAN_SET_LOUDNESS        = MCI_AMP_SET_LOUDNESS;
  MCI_AMP_CAN_SET_MUTE            = MCI_AMP_SET_MUTE;
  MCI_AMP_CAN_SET_REVERB          = MCI_AMP_SET_REVERB;
  MCI_AMP_CAN_SET_STEREOENHANCE   = MCI_AMP_SET_STEREOENHANCE;
  MCI_AMP_CAN_SET_CUSTOM1         = MCI_AMP_SET_CUSTOM1;
  MCI_AMP_CAN_SET_CUSTOM2         = MCI_AMP_SET_CUSTOM2;
  MCI_AMP_CAN_SET_CUSTOM3         = MCI_AMP_SET_CUSTOM3;
  MCI_AMP_CAN_SET_LRVOLUME        = MCI_AMP_SET_LRVOLUME;
  MCI_AMP_CAN_SET_BASS            = MCI_AMP_SET_BASS;
  MCI_AMP_CAN_SET_MID             = MCI_AMP_SET_MID;
  MCI_AMP_CAN_SET_TREBLE          = MCI_AMP_SET_TREBLE;
  MCI_AMP_CAN_SET_PITCH           = MCI_AMP_SET_PITCH;
  MCI_AMP_CAN_SET_GAIN            = MCI_AMP_SET_GAIN;
  MCI_AMP_CAN_SET_CHORUS          = MCI_AMP_SET_CHORUS;
  MCI_AMP_CAN_SET_VOLUME          = MCI_AMP_SET_VOLUME;

  // Potential values for the ulExtended field of MCI_AMP_GETDEVCAPS_PARMS
  MCI_MIXER_LINE                  = $00000001;

type
  // Parameter structure for the MCI_AMP_GETDEVCAPS
  mci_Amp_GetDevCaps_Parms = record
    hwndCallback  : uLong;                     // PM window handle for MCI notify message
    ulReturn      : uLong;                     // Return field
    ulItem        : uLong;                     // Item field for GETDEVCAPS item to query
    usMessage     : uShort;                    // Field to hold MCI message to query
    usReserved0   : uShort;                    // Reserved field
    ulLength      : uLong;                     // Length of structure in uLongS
    ulValue       : uLong;                     // Value to determine caps
    ulAttribute   : uLong;                     // Flags to modified the extended parms
    ulExtended    : uLong;                     // Extended flags field
  end;
  pmci_Amp_GetDevCaps_Parms = ^mci_Amp_GetDevCaps_Parms;

const
  // Values for the ulFlags field of MCI_MIXEVENT_PARMS
  MCI_MIX_ATTRIBUTE             = $00000001;
  MCI_MIX_CONNECTOR             = $00000002;

  // Values for the lParam field for mix_notify
  MCI_MIXNOTIFY_ON              = $00000004;
  MCI_MIXNOTIFY_OFF             = $00000008;

  // Value to indicate type of MM_MCIEVENT
  MCI_MIXEVENT                  = $00000001;

type
  // Parameter structure for the MCI_MIXEVENT_PARMS
  mci_MixEvent_Parms = record
    ulLength         : uLong;                  // Length of struct
    hwndMixer        : hwnd;                   // window to inform of mixer changes
    ulFlags          : uLong;                  // Either MCI_MIX_ATTRIBUTE
                                               //      or MCI_MIX_CONNECTOR
    usDeviceID       : uShort;                 // device id to notify of the change
    ulDeviceType     : uLong;                  // Device Type which generated the change
    ulDeviceOrdinal  : uLong;                  // Ordinal of device Type
    ulAttribute      : uLong;                  // Attribute that changed(volume, bass etc.)
    ulValue          : uLong;                  // new value of the attribute which changed
    ulConnectorType  : uLong;                  // Connector Type
    ulConnectorIndex : uLong;                  // Connector Index
    ulConnStatus     : uLong;                  // Is connector enabled/disabled.
  end;
  pmci_MixEvent_Parms = ^mci_MixEvent_Parms;

const
  // flag values for the MCI_GETIMAGEBUFFER and MCI_SETIMAGEBUFFER msg
  //   $000$X00 are reserved for MCI_GETIMAGEBUFFER and
  //     MCI_SETIMAGEBUFFER Flags
  //   MCI_CONVERT is defined by MCI_CAPTURE message as $00001000
  MCI_USE_HW_BUFFER             = $00000400;
  MCI_GET_HW_BUFFER_PTR         = $00000800;

type
  // parm structure for MCI_GETIMAGEBUFFER and
  //                    MCI_SETIMAGEBUFFER messages
  mci_Image_Parms = record
    hwndCallback       : hwnd;                 // PM window handle for MCI notify message
    ulPelFormat        : uLong;                // Format of the image data returned
    usBitCount         : uShort;               // Number of bitsimage data returned
    usReserved0        : uShort;               // Reserved field
    ulImageCompression : uLong;                //
    rect               : RectL;                // Image area to get/set
    pPelBuffer         : Pointer;              // Pel data buffer
    ulPelBufferHeight  : uLong;                // Number of rows in buffer
    ulPelBufferWidth   : uLong;                // Pels per row in buffer
    ulBufLen           : uLong;                // Pel data buffer length in bytes
  end;
  pmci_Image_Parms = ^mci_Image_Parms;

const
  // flags for the MCI_GETIMAGEPALETTE message
  //  $000$X00 are reserved for MCI_GETIMAGEPALETTE flags
  MCI_FIND_BEST_REGISTERED      = $00000100;
  MCI_QUERY_REGISTERED_MAP      = $00000200;
  MCI_QUERY_REGISTERED_MAP_SIZE = $00000400;

type
  // parameter structure for MCI_GETIMAGEPALETTE and
  //    MCI_SETIMAGEPALETTE messages
  mci_Palette_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    usRegisteredMap  : uShort;                 // Id of the palette from the registed color map
    usReserved0      : uShort;                 // Reserved field
    ulPalEntries     : uLong;                  // size of the palette returned
    pPalette         : Pointer;                // pointer to the palette
  end;
  pmci_Palette_Parms = ^mci_Palette_Parms;

  // Parameter structure for the MCI_GETTOC message
  mci_Toc_Rec = record
    TrackNum         : BYTE;                   // Returned Track Number
    ulStartAddr      : uLong;                  // Starting address of the track in MMTIME format
    ulEndAddr        : uLong;                  // Ending address of the track in MMTIME format
    Control          : BYTE;                   // Track Control information
    usCountry        : uShort;                 // Country
    ulOwner          : uLong;                  // Owner
    ulSerialNum      : uLong;                  // Serial Number
  end;
  pTocRec = ^mci_Toc_Rec;

  mci_Toc_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    pBuf             : pTocRec;                // Pointer to array MCI_TOC_REC structures to
                                               // be filled in by the mci device
    ulBufSize        : uLong;                  // Size of the array
  end;
  pmci_Toc_Parms = ^mci_Toc_Parms;

const
  // parameters for the MCI_GROUP message
  //     $0$XXX00 are reserved for MCI_GROUP flags
  MCI_SYNCHRONIZE               = $00000100;
  MCI_NOPIECEMEAL               = $00000200;
  MCI_GROUP_MAKE                = $00000400;
  MCI_GROUP_DELETE              = $00000800;
  MCI_GROUP_ALIAS               = $00001000;
  MCI_GROUP_MASTER              = $00002000;
  MCI_GROUP_NONE                = $00004000;   // No group!

type
  mci_Group_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message.
    usGroupID                   : uShort;      // GroupID
    usReserved0                 : uShort;      // RESERVED
    ulStructLength              : uLong;       // Length of Structure in ULONGS.
    usMasterID                  : uShort;      // ID of Master device in Synchrounous groups.
    usReserved1                 : uShort;      // RESERVED
    pszGroupAlias               : pChar;       // Pointer to Alias Name.
    ulNumDevices                : uLong;       // Number of Devices in group.
    paulDeviceID                : PuLong;      // Array of Device ids in the group.
  end;
  pmci_Group_Parms = ^mci_Group_Parms;

const
  // flags for the MCI_INFO message
  //     $0000$00 are reserved for MCI_INFO flags
  MCI_INFO_PRODUCT              = $00000100;
  MCI_INFO_FILE                 = $00000200;

  // CD Audio                MCI_INFO
  MCI_CD_INFO_ID                = $00010000;
  MCI_CD_INFO_UPC               = $00020000;

  // Videodisc               MCI_INFO
  MCI_VD_INFO_LABEL             = $00001000;

  // Digital Video           MCI_INFO
  MCI_DGV_INFO_VIDEO_FILE       = $00001000;
  MCI_DGV_INFO_IMAGE_FILE       = $00002000;
  MCI_DGV_INFO_REGION           = $00004000;
  MCI_DGV_INFO_REGION_TEXT      = $00008000;
  MCI_DGV_INFO_TEXT             = $00010000;

  // Video Overlay           MCI_INFO
  MCI_OVLY_INFO_TEXT            = $00010000;

type
  mci_Info_Parms = record
    hwndCallback      : hwnd;                  // PM window handle for MCI notify message
    pszReturn         : pChar;                 // Pointer to return buffer
    ulRetSize         : uLong;                 // Return buffer size
  end;
  pmci_Info_Parms = ^mci_Info_Parms;

  // Parameters and flags for the MCI_LOAD message
  //     $0000$00 are reserved for MCI_LOAD flags
  mci_Load_Parms = record
    hwndCallback      : hwnd;                  // PM window handle for MCI notify message
    pszElementName    : pChar;                 // File name to loads
  end;
  pmci_Load_Parms = ^mci_Load_Parms;

const
  // Parameters and flags for the MCI_MASTERAUDIO
  //     $00$XX00 are reserved for MCI_MASTERAUDIO flags
  MCI_ON                        = $00000100;
  MCI_OFF                       = $00000200;
  MCI_HEADPHONES                = $00000400;
  MCI_SPEAKERS                  = $00000800;
  MCI_MASTERVOL                 = $00001000;
  MCI_SAVESETTING               = $00002000;
  MCI_QUERYSAVEDSETTING         = $00004000;
  MCI_QUERYCURRENTSETTING       = $00008000;

type
  mci_MasterAudio_Parms = record
    hwndDummyCallback : hwnd;                  // Notify not allowed for this message
    ulReturn          : uLong;                 // Return field for query information
    ulMasterVolume    : uLong;                 // Master volume field
  end;
  pmci_MasterAudio_Parms = ^mci_MasterAudio_Parms;

const
  // Parameters and flags for the MCI_OPEN message
  //     $000$X00 are reserved for MCI_OPEN flags
  MCI_OPEN_ELEMENT              = $00000100;
  MCI_OPEN_ALIAS                = $00000200;
  MCI_OPEN_ELEMENT_ID           = $00000400;
  MCI_OPEN_PLAYLIST             = $00000800;
  MCI_OPEN_TYPE_ID              = $00001000;
  MCI_OPEN_SHAREABLE            = $00002000;
  MCI_OPEN_MMIO                 = $00004000;
  MCI_READONLY                  = $00008000;

  // Parameters and flags for the MCI_OPEN message
  // Digital Video, Video Overlay specific
  MCI_VID_OPEN_PARENT           = $01000000;
  MCI_DGV_OPEN_PARENT           = MCI_VID_OPEN_PARENT;
  MCI_OVLY_OPEN_PARENT          = MCI_VID_OPEN_PARENT;

type
  mci_Open_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    usDeviceID       : uShort;                 // Device ID returned to user
    usReserved0      : uShort;                 // Reserved
    pszDeviceType    : pChar;                  // Device name from SYSTEM.INI
    pszElementName   : pChar;                  // Typically a file name or NULL
    pszAlias         : pChar;                  // Optional device alias
  end;
  pmci_Open_Parms = ^mci_Open_Parms;

  // Parameters for the AMP MCI_OPEN message
  mci_Amp_Open_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    usDeviceID       : uShort;                 // Device ID returned to user
    usReserved0      : uShort;                 // Reserved field
    pszDeviceType    : pChar;                  // Device name from SYSTEM.INI
    pszElementName   : pChar;                  // Typically a file name or NULL
    pszAlias         : pChar;                  // Optional device alias
    pDevDataPtr      : Pointer;                // Pointer to device data
  end;
  pmci_Amp_Open_Parms = ^mci_Amp_Open_Parms;

  // Parameters for MCI_OPEN message for video devices
  mci_Vid_Open_Parms = record
    hwndCallback     : hwnd;                   // PM window handle for MCI notify message
    usDeviceID       : uShort;                 // Device ID returned to user
    usReserved0      : uShort;                 // Reserved field
    pszDeviceType    : pChar;                  // Device name from SYSTEM.INI
    pszElementName   : pChar;                  // Typically a file name or NULL
    pszAlias         : pChar;                  // Optional device alias
    hwndParent       : hwnd;                   // Parent window handle
  end;
  pmci_Vid_Open_Parms = ^mci_Vid_Open_Parms;

  mci_dgv_Open_Parms   = mci_Vid_Open_Parms;
  pmci_dgv_Open_Parms  = ^mci_dgv_Open_Parms;

  mci_Ovly_Open_Parms  = mci_Vid_Open_Parms;
  pmci_Ovly_Open_Parms = ^mci_Ovly_Open_Parms;

const
  // MCI_PLAY flag values for videodisc
  MCI_VD_PLAY_REVERSE           = $00001000;
  MCI_VD_PLAY_FAST              = $00002000;
  MCI_VD_PLAY_SPEED             = $00004000;
  MCI_VD_PLAY_SCAN              = $00008000;
  MCI_VD_PLAY_SLOW              = $00010000;

  // MCI_PLAY flag values for digital video
  MCI_DGV_PLAY_REVERSE          = $00001000;
  MCI_DGV_PLAY_FAST             = $00002000;
  MCI_DGV_PLAY_SPEED            = $00004000;
  MCI_DGV_PLAY_SCAN             = $00008000;
  MCI_DGV_PLAY_SLOW             = $00010000;
  MCI_DGV_PLAY_REPEAT           = $00020000;

type
  mci_Play_Parms = record
    hwndCallback      : hwnd;
    ulFrom            : uLong;
    ulTo              : uLong;
  end;
  pmci_Play_Parms = ^mci_Play_Parms;

  mci_VD_Play_Parms = record
    hwndCallback      : hwnd;
    ulFrom            : uLong;
    ulTo              : uLong;
    ulFactor          : uLong;
  end;
  pmci_VD_Play_Parms = ^mci_VD_Play_Parms;

  mci_DGV_play_Parms = record
    hwndCallback      : hwnd;
    ulFrom            : uLong;
    ulTo              : uLong;
    ulSpeed           : uLong;
  end;
  pmci_DGV_play_Parms = ^mci_DGV_play_Parms;

const
  // Parameters for the MCI_PUT  message
  //     $0000$00 are reserved for MCI_PUT  flags
  MCI_VID_PUT_RECT              = $00000100;
  MCI_VID_PUT_DESTINATION       = $00000200;
  MCI_VID_PUT_SOURCE            = $00000400;
  MCI_VID_PUT_WINDOW_MOVE       = $00000800;
  MCI_VID_PUT_WINDOW_SIZE       = $00001000;

  MCI_DGV_PUT_RECT              = MCI_VID_PUT_RECT;
  MCI_DGV_PUT_DESTINATION       = MCI_VID_PUT_DESTINATION;
  MCI_DGV_PUT_SOURCE            = MCI_VID_PUT_SOURCE;
  MCI_DGV_PUT_WINDOW_MOVE       = MCI_VID_PUT_WINDOW_MOVE;
  MCI_DGV_PUT_WINDOW_SIZE       = MCI_VID_PUT_WINDOW_SIZE;
  MCI_DGV_MONITOR               = $00010000;
  MCI_DGV_RECORD                = $00020000;

  MCI_OVLY_PUT_RECT             = MCI_VID_PUT_RECT;
  MCI_OVLY_PUT_DESTINATION      = MCI_VID_PUT_DESTINATION;
  MCI_OVLY_PUT_SOURCE           = MCI_VID_PUT_SOURCE;
  MCI_OVLY_PUT_WINDOW_MOVE      = MCI_VID_PUT_WINDOW_MOVE;
  MCI_OVLY_PUT_WINDOW_SIZE      = MCI_VID_PUT_WINDOW_SIZE;

type
  // Rectangle parameters for MCI_PUT, MCI_WHERE,
  // MCI_FREEZE, and MCI_UNFREEZE
  mci_Vid_Rect_Parms = record
    hwndCallback      : hwnd;                  // PM window handle for MCI notify message
    rc                : RectL;                 // rectangle array specifying the offset
                                               // and size of a rectangle
  end;

  mci_Dgv_Rect_Parms            = mci_Vid_Rect_Parms;
  pmci_Dgv_Rect_Parms           = ^mci_Dgv_Rect_Parms;

  mci_Ovly_Rect_Parms           = mci_Vid_Rect_Parms;
  pmci_Ovly_Rect_Parms          = ^mci_Ovly_Rect_Parms;

const
  // Parameters for the MCI_RECORD message
  //    $0000$00 are reserved for MCI_RECORD flags
  MCI_RECORD_INSERT             = $00000100;
  MCI_RECORD_OVERWRITE          = $00000200;

  MCI_DGV_RECORD_RECT           = $00000400;

type
  mci_Record_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulFrom                      : uLong;       // Record from position
    ulTo                        : uLong;       // Record to position
  end;
  pmci_Record_Parms = ^mci_Record_Parms;

const
  // Parameters for the MCI_RELEASEDEVICE message
  //     $XXXXXX00 are reserved for MCI_RELEASEDEVICE message
  MCI_RETURN_RESOURCE           = $00000100;

  // parameters for the MCI_RESTORE message
  //     $000$X00 are reserved for MCI_RESTORE flags
  //     MCI_CONVERT is defined by MCI_CAPTURE message as $00001000
  MCI_RESTORE_SRC_RECT          = $00000100;
  MCI_RESTORE_DEST_RECT         = $00000200;

type
  mci_Restore_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    SrcRect                     : RectL;       // Rectangle array specifying the source
                                               // area to be restored
    RestRect                    : RectL;       // Rectangle array specifying the destination
                                               // area to be restored
  end;
  pmci_Restore_Parms = ^mci_Restore_Parms;

const
  //  parameters for the MCI_SAVE  message
  //      $0000$00 are reserved for MCI_SAVE flags
  MCI_SAVE_FILE                 = $00000100;

  // Digital Video               MCI_SAVE
  MCI_DGV_SAVE_VIDEO_FILE       = $00001000;
  MCI_DGV_SAVE_IMAGE_FILE       = $00002000;

type
  mci_Save_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    pszFileName                 : pChar;       // Filename to save data to
  end;
  pmci_Save_Parms = ^mci_Save_Parms;

const
  // parameters for the MCI_SEEK message
  //     $0000$00 are reserved for MCI_SEEK flags
  MCI_TO_START                  = $00000100;
  MCI_TO_END                    = $00000200;

  // Digital Video               MCI_SEEK

  MCI_DGV_SEEK_TO_NEAREST_IFRAME = $00100000;

  // Videodisc                   MCI_SEEK
  MCI_VD_SEEK_REVERSE           = $00001000;

type
  mci_Seek_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulTo                        : uLong;       // Seek to this position
  end;
  pmci_Seek_Parms = ^mci_Seek_Parms;

const
  // Flags for the MCI_SET message
  //     $0$XXX00 are reserved for MCI_SET flags
  MCI_SET_ITEM                  = $00000100;
  MCI_SET_ON                    = $00000200;
  MCI_SET_OFF                   = $00000400;
  MCI_SET_VIDEO                 = $00000800;
  MCI_SET_AUDIO                 = $00001000;
  MCI_SET_DOOR_OPEN             = $00002000;
  MCI_SET_DOOR_CLOSED           = $00004000;
  MCI_SET_SPEED_FORMAT          = $00008000;
  MCI_SET_TIME_FORMAT           = $00010000;
  MCI_SET_DOOR_LOCK             = $00020000;
  MCI_SET_DOOR_UNLOCK           = $00040000;
  MCI_SET_VOLUME                = $00080000;
  MCI_SET_ITEM_FOURCC           = $00100000;
  MCI_SET_REVERSE               = $00200000;

  // Values for the ulAudio field
  MCI_SET_AUDIO_ALL             = $00000000;
  MCI_SET_AUDIO_LEFT            = $00000001;
  MCI_SET_AUDIO_RIGHT           = $00000002;

  // MCI_SET flags for CDXA
  MCI_CDXA_SET_CHANNEL          = $01000000;
  MCI_CDXA_AUDIO_DEVICE         = $10000000;
  MCI_CDXA_AUDIO_BUFFER         = $02000000;
  MCI_CDXA_VIDEO_BUFFER         = $04000000;
  MCI_CDXA_DATA_BUFFER          = $08000000;

  // MCI_SET flags for videodisc
  MCI_VD_SET_ON                 = MCI_SET_ON;
  MCI_VD_SET_OFF                = MCI_SET_OFF;
  MCI_VD_SET_VIDEO              = MCI_SET_VIDEO;
  MCI_VD_SET_CHANNEL            = $00100000;
  MCI_VD_SET_DISPLAY            = $00200000;
  MCI_VD_SET_DONTCARE           = $00400000;   // Dont care!

  // Generic MCI_SET item values for video devices
  MCI_VID_SET_VIDEO_COMPRESSION = MCI_VID_ITEM_BASE;
  MCI_VID_SET_IMAGE_COMPRESSION = MCI_VID_ITEM_BASE+1;
  MCI_VID_SET_IMAGE_BITSPERPEL  = MCI_VID_ITEM_BASE+2;
  MCI_VID_SET_IMAGE_PELFORMAT   = MCI_VID_ITEM_BASE+3;
  MCI_VID_SET_BRIGHTNESS        = MCI_VID_ITEM_BASE+4;
  MCI_VID_SET_CONTRAST          = MCI_VID_ITEM_BASE+5;
  MCI_VID_SET_HUE               = MCI_VID_ITEM_BASE+6;
  MCI_VID_SET_SATURATION        = MCI_VID_ITEM_BASE+7;
  MCI_VID_SET_SHARPNESS         = MCI_VID_ITEM_BASE+8;
  MCI_VID_SET_GREYSCALE         = MCI_VID_ITEM_BASE+9;
  MCI_VID_SET_IMAGE_QUALITY     = MCI_VID_ITEM_BASE+10;
  MCI_VID_SET_VIDEO_QUALITY     = MCI_VID_ITEM_BASE+11;
  MCI_VID_SET_IMAGE_COMPRESSION_METHOD = MCI_VID_ITEM_BASE+12;
  MCI_VID_SET_MINIMUM_VIDEO_REFRESH_RATE = MCI_VID_ITEM_BASE+13;
  MCI_VID_SET_IMAGE_FILE_FORMAT = MCI_VID_ITEM_BASE+14;
  MCI_VID_SET_REF_INTERVAL      = MCI_VID_ITEM_BASE+15;
  MCI_VID_SET_MAXDATARATE       = MCI_VID_ITEM_BASE+16;
  MCI_VID_SET_VIDEO_FILE_FORMAT = MCI_VID_ITEM_BASE+17;

  // MCI_SET item values for video overlay
  MCI_OVLY_SET_IMAGE_COMPRESSION = MCI_VID_SET_IMAGE_COMPRESSION;
  MCI_OVLY_SET_IMAGE_BITSPERPEL = MCI_VID_SET_IMAGE_BITSPERPEL;
  MCI_OVLY_SET_IMAGE_PELFORMAT  = MCI_VID_SET_IMAGE_PELFORMAT;
  MCI_OVLY_SET_BRIGHTNESS       = MCI_VID_SET_BRIGHTNESS;
  MCI_OVLY_SET_CONTRAST         = MCI_VID_SET_CONTRAST;
  MCI_OVLY_SET_HUE              = MCI_VID_SET_HUE;
  MCI_OVLY_SET_SATURATION       = MCI_VID_SET_SATURATION;
  MCI_OVLY_SET_SHARPNESS        = MCI_VID_SET_SHARPNESS;
  MCI_OVLY_SET_GREYSCALE        = MCI_VID_SET_GREYSCALE;
  MCI_OVLY_SET_IMAGE_QUALITY    = MCI_VID_SET_IMAGE_QUALITY;
  MCI_OVLY_SET_IMAGE_COMPRESSION_METHOD = MCI_VID_SET_IMAGE_COMPRESSION_METHOD;
  MCI_OVLY_SET_MINIMUM_VIDEO_REFRESH_RATE = MCI_VID_SET_MINIMUM_VIDEO_REFRESH_RATE;
  MCI_OVLY_SET_IMAGE_FILE_FORMAT = MCI_VID_SET_IMAGE_FILE_FORMAT;

  // MCI_SET item values for digital video
  MCI_DGV_SET_VIDEO_COMPRESSION = MCI_VID_SET_VIDEO_COMPRESSION;
  MCI_DGV_SET_IMAGE_COMPRESSION = MCI_VID_SET_IMAGE_COMPRESSION;
  MCI_DGV_SET_IMAGE_BITSPERPEL  = MCI_VID_SET_IMAGE_BITSPERPEL;
  MCI_DGV_SET_IMAGE_PELFORMAT   = MCI_VID_SET_IMAGE_PELFORMAT;
  MCI_DGV_SET_BRIGHTNESS        = MCI_VID_SET_BRIGHTNESS;
  MCI_DGV_SET_CONTRAST          = MCI_VID_SET_CONTRAST;
  MCI_DGV_SET_HUE               = MCI_VID_SET_HUE;
  MCI_DGV_SET_SATURATION        = MCI_VID_SET_SATURATION;
  MCI_DGV_SET_SHARPNESS         = MCI_VID_SET_SHARPNESS;
  MCI_DGV_SET_GREYSCALE         = MCI_VID_SET_GREYSCALE;
  MCI_DGV_SET_IMAGE_QUALITY     = MCI_VID_SET_IMAGE_QUALITY;
  MCI_DGV_SET_VIDEO_QUALITY     = MCI_VID_SET_VIDEO_QUALITY;
  MCI_DGV_SET_IMAGE_COMPRESSION_METHOD = MCI_VID_SET_IMAGE_COMPRESSION_METHOD;
  MCI_DGV_SET_MONITOR           = MCI_SET_MONITOR;
  MCI_DGV_SET_MINIMUM_VIDEO_REFRESH_RATE = MCI_VID_SET_MINIMUM_VIDEO_REFRESH_RATE;
  MCI_DGV_SET_IMAGE_FILE_FORMAT = MCI_VID_SET_IMAGE_FILE_FORMAT;
  MCI_DGV_SET_REF_INTERVAL      = MCI_VID_SET_REF_INTERVAL;
  MCI_DGV_SET_MAXDATARATE       = MCI_VID_SET_MAXDATARATE;
  MCI_DGV_SET_VIDEO_FILE_FORMAT = MCI_VID_SET_VIDEO_FILE_FORMAT;

  MCI_DGV_SET_AUDIO_COMPRESSION = MCI_DGV_ITEM_BASE;
  MCI_DGV_SET_AUDIO_QUALITY     = MCI_DGV_ITEM_BASE+1;
  MCI_DGV_SET_CHANNELS          = MCI_DGV_ITEM_BASE+2;
  MCI_DGV_SET_BITSPERSAMPLE     = MCI_DGV_ITEM_BASE+3;
  MCI_DGV_SET_SAMPLESPERSEC     = MCI_DGV_ITEM_BASE+4;
  MCI_DGV_SET_FORMATTAG         = MCI_DGV_ITEM_BASE+5;
  MCI_DGV_SET_BLOCKALIGN        = MCI_DGV_ITEM_BASE+6;
  MCI_DGV_SET_AVGBYTESPERSEC    = MCI_DGV_ITEM_BASE+7;

  MCI_DGV_SET_VIDEO_COMPRESSION_SUBTYPE = MCI_DGV_ITEM_BASE+8;
  MCI_DGV_SET_VIDEO_RECORD_RATE = MCI_DGV_ITEM_BASE+9;
  MCI_DGV_SET_VIDEO_RECORD_FRAME_DURATION = MCI_DGV_ITEM_BASE+10;
  MCI_DGV_SET_RECORD_AUDIO      = MCI_DGV_ITEM_BASE+11;
  MCI_DGV_SET_TRANSPARENT_COLOR = MCI_DGV_ITEM_BASE+12;
  MCI_DGV_SET_GRAPHIC_TRANSPARENT_COLOR = MCI_DGV_ITEM_BASE+12;
  MCI_DGV_SET_AUDIOSYNC         = MCI_DGV_ITEM_BASE+13;
  MCI_DGV_SET_VIDEO_TRANSPARENT_COLOR = MCI_DGV_ITEM_BASE+14;

  // Video file format
  MCI_VID_FILE_FORMAT_AVI       = $20495641;

  // Audio/video/image compression types
  MCI_AUD_COMP_ADPCM4           = $00000001;
  MCI_AUD_COMP_PCM8             = $00000002;

  MCI_VID_COMP_RTV_2_0          = $00000101;
  MCI_VID_COMP_RTV_2_1          = $00000102;
  MCI_VID_COMP_ULTI             = $49544C55;
  MCI_VID_COMP_RT21             = $31325452;
  MCI_VID_COMP_NONE             = $20424944;   // This is 'DIB ' now.

  MCI_IMG_COMP_NONE             = $00000201;
  MCI_IMG_COMP_PIC9_1_0         = $00000202;
  MCI_IMG_COMP_PIC16_1_0        = $00000203;
  MCI_IMG_COMP_JPEG9            = $00000204;
  MCI_IMG_COMP_JPEG9_1_0        = MCI_IMG_COMP_JPEG9;
  MCI_IMG_COMP_BMP_RLE4         = $00000205;
  MCI_IMG_COMP_BMP_RLE8         = $00000206;
  MCI_IMG_COMP_JPEGN            = $00000207;

  // PEL Formats (video/image)
  MCI_VID_PALETTE               = $00000001;
  MCI_VID_RGB                   = $00000002;
  MCI_VID_YUV                   = $00000003;

  MCI_IMG_PALETTE               = MCI_VID_PALETTE;
  MCI_IMG_RGB                   = MCI_VID_RGB;
  MCI_IMG_YUV                   = MCI_VID_YUV;

  // Audio/video/image quality levels
  MCI_AUD_QUALITY_HIGH          = $00000001;
  MCI_AUD_QUALITY_MED           = $00000002;
  MCI_AUD_QUALITY_LOW           = $00000003;

  MCI_VID_QUALITY_HIGH          = $00000101;
  MCI_VID_QUALITY_MED           = $00000102;
  MCI_VID_QUALITY_LOW           = $00000103;
  MCI_VID_QUALITY_BEST          = MCI_VID_QUALITY_HIGH;
  MCI_VID_QUALITY_CDROM         = MCI_VID_QUALITY_MED;
  MCI_VID_QUALITY_COMPACT       = MCI_VID_QUALITY_LOW;
  MCI_VID_QUALITY_BETTER        = MCI_VID_QUALITY_MED;
  MCI_VID_QUALITY_GOOD          = MCI_VID_QUALITY_LOW;

  MCI_IMG_QUALITY_HIGH          = $00000201;
  MCI_IMG_QUALITY_MED           = $00000202;
  MCI_IMG_QUALITY_LOW           = $00000203;

  // MCI_SET flags for wave audio
  MCI_WAVE_SET_SAMPLESPERSEC    = $01000000;
  MCI_WAVE_SET_AVGBYTESPERSEC   = $02000000;
  MCI_WAVE_SET_BLOCKALIGN       = $04000000;
  MCI_WAVE_SET_FORMATTAG        = $08000000;
  MCI_WAVE_SET_CHANNELS         = $10000000;
  MCI_WAVE_SET_BITSPERSAMPLE    = $80000000;

  // Wave format tag defines
  MCI_WAVE_FORMAT_PCM           = DATATYPE_WAVEFORM;
  MCI_WAVE_FORMAT_ADPCM         = $0002;
  MCI_WAVE_FORMAT_IBM_CVSD      = $0005;
  MCI_WAVE_FORMAT_ALAW          = DATATYPE_RIFF_ALAW;
  MCI_WAVE_FORMAT_MULAW         = DATATYPE_RIFF_MULAW;
  MCI_WAVE_FORMAT_OKI_ADPCM     = $0010;
  MCI_WAVE_FORMAT_DVI_ADPCM     = $0011;
  MCI_WAVE_FORMAT_DIGISTD       = $0015;
  MCI_WAVE_FORMAT_DIGIFIX       = $0016;
  MCI_WAVE_FORMAT_AVC_ADPCM     = DATATYPE_ADPCM_AVC;
  MCI_WAVE_FORMAT_IBM_ADPCM     = DATATYPE_ADPCM_AVC;
  MCI_WAVE_FORMAT_IBM_MULAW     = DATATYPE_MULAW;
  MCI_WAVE_FORMAT_IBM_ALAW      = DATATYPE_ALAW;
  MCI_WAVE_FORMAT_CT_ADPCM      = DATATYPE_CT_ADPCM;
  MCI_WAVE_FORMAT_MPEG1         = DATATYPE_MPEG1AUDIO;

  // MCI_SET flags for sequencer
  MCI_SEQ_SET_TEMPO             = $00100000;
  MCI_SEQ_SET_PORT              = $00200000;
  MCI_SEQ_ENABLE_PORT_MAPPER    = $00400000;
  MCI_SEQ_DISABLE_PORT_MAPPER   = $00800000;
  MCI_SEQ_SET_OFFSET            = $01000000;
  MCI_SEQ_SET_MASTER            = $02000000;
  MCI_SEQ_SET_SLAVE             = $04000000;

  // SEQ time formats
  MCI_SEQ_SET_SMPTE_24          = $00000100;
  MCI_SEQ_SET_SMPTE_25          = $00000200;
  MCI_SEQ_SET_SMPTE_30          = $00000300;
  MCI_SEQ_SET_SMPTE_30DROP      = $00000400;
  MCI_SEQ_SET_SONGPTR           = $00000500;

  // SEQ synchronization types
  MCI_SEQ_MIDI                  = $00000001;
  MCI_SEQ_SMPTE                 = $00000002;
  MCI_SEQ_FILE                  = $00000003;
  MCI_SEQ_NONE                  = $00000004;

  // SEQ PORT TYPES
  MCI_SET_NONE                  = $10000000;
  MIDI_MAPPER                   = $20000000;
  MCI_MIDI_MAPPER               = MIDI_MAPPER;

type
  mci_Set_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulTimeFormat                : uLong;       // Time format to be used by the device
    ulSpeedFormat               : uLong;       // Speed format used by this device
    ulAudio                     : uLong;       // Channel number for this operation
                                               // (MCI_SET_AUDIO_LEFT, MCI_SET_AUDIO_RIGHT,
                                               //  MCI_SET_AUDIO_ALL)
    ulLevel                     : uLong;       // Volume, treble or bass level as % of max.
    ulOver                      : uLong;       // Delay time for vectored change in millisecond
    ulItem                      : uLong;       // Item field for set item flags
    ulValue                     : uLong;       // Value associated with item flag
  end;
  pmci_Set_Parms = ^mci_Set_Parms;

  mci_Amp_Set_Parms            = mci_Set_Parms;
  pmci_Amp_Set_Parms           = ^mci_Amp_Set_Parms;

  mci_DGV_Set_Parms            = mci_Set_Parms;
  pmci_DGV_Set_Parms           = ^mci_DGV_Set_Parms;

  mci_Ovly_Set_Parms           = mci_Set_Parms;
  pmci_Ovly_Set_Parms          = ^mci_Ovly_Set_Parms;

  mci_CDXA_Set_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulTimeFormat                : uLong;       // Time format to be used by the device
    ulSpeedFormat               : uLong;       // Speed format used by this device
    ulAudio                     : uLong;       // Channel number for this operation
                                               // (MCI_SET_AUDIO_LEFT, MCI_SET_AUDIO_RIGHT,
                                               //  MCI_SET_AUDIO_ALL)
    ulLevel                     : uLong;       // Volume, treble or bass level as % of max.
    ulOver                      : uLong;       // Delay time for vectored change in milliseconds
    ulItem                      : uLong;       // Item field for set item flags
    ulValue                     : uLong;       // Value associated with item flag
    ulChannel                   : uLong;       // Channel number
    pPlayList                   : Pointer;     // Pointer to play list
    ulPlayListSize              : uLong;       // Play list size
  end;
  pmci_CDXA_Set_Parms = ^mci_CDXA_Set_Parms;

  mci_VD_Set_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulTimeFormat                : uLong;       // Time format to be used by the device
    ulSpeedFormat               : uLong;       // Speed format used by this device
    ulAudio                     : uLong;       // Channel number for this operation
                                               // (MCI_SET_AUDIO_LEFT, MCI_SET_AUDIO_RIGHT,
                                               //  MCI_SET_AUDIO_ALL)
    ulLevel                     : uLong;       // Volume, treble or bass level as % of max.
    ulOver                      : uLong;       // Delay time for vectored change in milliseconds
    ulItem                      : uLong;       // Item field for set item flags
    ulValue                     : uLong;       // Value associated with item flag
    ulChannel                   : uLong;       // Videodisc channel
  end;
  pmci_VD_Set_Parms = ^mci_VD_Set_Parms;

  mci_Wave_Set_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulTimeFormat                : uLong;       // Time format to be used by the device
    ulSpeedFormat               : uLong;       // Speed format used by this device
    ulAudio                     : uLong;       // Channel number for this operation
                                               // (MCI_SET_AUDIO_LEFT, MCI_SET_AUDIO_RIGHT,
                                               //  MCI_SET_AUDIO_ALL)
    ulLevel                     : uLong;       // Volume, trebble or bass level as % of max.
    ulOver                      : uLong;       // Delay time for vectored change in milliseconds
    ulItem                      : uLong;       // Item field for set item flags
    ulValue                     : uLong;       // Value associated with item flag
    usInput                     : uShort;      // Channel for input
    usReserved0                 : uShort;      // Reserved field
    usOutput                    : uShort;      // Channel for output
    usReserved1                 : uShort;      // Reserved field
    usFormatTag                 : uShort;      // Format tag
    usReserved2                 : uShort;      // Reserved field
    usChannels                  : uShort;      // mono(1) or stereo(2)
    usReserved3                 : uShort;      // Reserved field
    ulSamplesPerSec             : uLong;       // Samples per seconds
    ulAvgBytesPerSec            : uLong;       // Bytes per seconds
    usBlockAlign                : uShort;      // Block alignment of data
    usReserved4                 : uShort;      // Reserved field
    usBitsPerSample             : uShort;      // Bits per seconds
    usReserved5                 : uShort;      // Reserved field
  end;
  pmci_Wave_Set_Parms = ^mci_Wave_Set_Parms;

  mci_Seq_Set_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulTimeFormat                : uLong;       // Time format to be used by the device
    ulSpeedFormat               : uLong;       // Speed format used by this device
    ulAudio                     : uLong;       // Channel number for this operation
                                               // (MCI_SET_AUDIO_LEFT, MCI_SET_AUDIO_RIGHT,
                                               //  MCI_SET_AUDIO_ALL)
    ulLevel                     : uLong;       // Volume, trebble or bass level as % of max.
    ulOver                      : uLong;       // Delay time for vectored change in millisecond
    ulItem                      : uLong;       // Item field for set item flags
    ulValue                     : uLong;       // Value associated with item flag
    ulTempo                     : uLong;       // Specified the tempo
    ulPort                      : uLong;       // Output port
    ulSlave                     : uLong;       // Unused field
    ulMaster                    : uLong;       // Unused field
    ulOffset                    : uLong;       // Specified the data offset
  end;
  pmci_Seq_Set_Parms = ^mci_Seq_Set_Parms;

const
  // parameters for the MCI_SET_CUEPOINT message
  //     $0000$00 are reserved for MCI_SET_CUEPOINT flags
  MCI_SET_CUEPOINT_ON           = $00000100;
  MCI_SET_CUEPOINT_OFF          = $00000200;

type
  mci_CuePoint_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulCuepoint                  : uLong;       // Specifies the cuepoint location
    usUserParm                  : uShort;      // User parmameter returned on cuepoint
                                               // notify message
    usReserved0                 : uShort;      // Reserved field
  end;
  pmci_CuePoint_Parms = ^mci_CuePoint_Parms;

const
  // parameters for the MCI_SETIMAGEPALETTE message
  //   $00$XX00 are reserved for MCI_SETIMAGEPALETTE flags
  MCI_SET_REGISTERED            = $00000100;

  // Flags and parameter structure for the MCI_SET_POSITION_ADVISE msg
  //     $0000$00 are reserved for MCI_SET_POSITION_ADVISE flags
  MCI_SET_POSITION_ADVISE_ON    = $00000100;
  MCI_SET_POSITION_ADVISE_OFF   = $00000200;

type
  mci_Position_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulUnits                     : uLong;       // Specifies position change notifiication
                                               // granularity
    usUserParm                  : uShort;      // User parameter returned on position change
                                               // notification message.
    Reserved0                   : uShort;      // Reserved field
    Reserved1                   : uLong;       // Reserved field
  end;
  pmci_Position_Parms = ^mci_Position_Parms;

  mci_Sync_Offset_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulOffset                    : uLong;       // Specifies the device media position offset
                                               // in the currently specified device units.
  end;
  pmci_Sync_Offset_Parms = ^mci_Sync_Offset_Parms;

const
  // Flags for the MCI_SPIN message
  //     $0000$00 are reserved for MCI_SPIN flags
  MCI_SPIN_UP                   = $00000100;
  MCI_SPIN_DOWN                 = $00000200;

  // MCI_STATUS message flags
  //     $00$XX00 are reserved for MCI_STATUS flags
  //     MCI_VOLUME and MCI_VOLUME_DELAY are $00000100 and $00000200
  MCI_STATUS_ITEM               = $00000100;
  MCI_STATUS_START              = $00000200;
  MCI_STATUS_CONNECTOR          = $00000400;

  // General MCI_STATUS item values
  MCI_STATUS_CURRENT_TRACK      = $00000001;
  MCI_STATUS_LENGTH             = $00000002;
  MCI_STATUS_MODE               = $00000003;
  MCI_STATUS_NUMBER_OF_TRACKS   = $00000004;
  MCI_STATUS_POSITION           = $00000005;
  MCI_STATUS_POSITION_IN_TRACK  = $00000006;
  MCI_STATUS_MEDIA_PRESENT      = $00000007;
  MCI_STATUS_VOLUME             = $00000008;
  MCI_STATUS_READY              = $00000009;
  MCI_STATUS_TIME_FORMAT        = $0000000A;
  MCI_STATUS_SPEED_FORMAT       = $0000000B;
  MCI_STATUS_MONITOR            = $0000000C;
  MCI_STATUS_AUDIO              = $0000000D;
  MCI_STATUS_VIDEO              = $0000000E;
  MCI_STATUS_CLIPBOARD          = $0000000F;
  MCI_STATUS_CAN_PASTE          = $00000010;
  MCI_STATUS_CAN_REDO           = $00000020;
  MCI_STATUS_CAN_UNDO           = $00000030;

  // ulValue field values for MCI_STATUS_AUDIO
  MCI_STATUS_AUDIO_ALL          = $00000000;
  MCI_STATUS_AUDIO_LEFT         = $00000001;
  MCI_STATUS_AUDIO_RIGHT        = $00000002;

  // MCI_STATUS item values for amp/mixer
  MCI_AMP_STATUS_PITCH          = MCI_AMP_ITEM_BASE;
  MCI_AMP_STATUS_TREBLE         = MCI_AMP_ITEM_BASE+1;
  MCI_AMP_STATUS_BASS           = MCI_AMP_ITEM_BASE+2;
  MCI_AMP_STATUS_BALANCE        = MCI_AMP_ITEM_BASE+3;
  MCI_AMP_STATUS_GAIN           = MCI_AMP_ITEM_BASE+4;
  MCI_AMP_STATUS_MONITOR        = MCI_AMP_ITEM_BASE+5;
  MCI_AMP_STATUS_MID            = MCI_AMP_ITEM_BASE+6;
  MCI_AMP_STATUS_VOLUME         = MCI_STATUS_VOLUME;
  MCI_AMP_STATUS_LOUDNESS       = MCI_AMP_ITEM_BASE+7;
  MCI_AMP_STATUS_CROSSOVER      = MCI_AMP_ITEM_BASE+8;
  MCI_AMP_STATUS_REVERB         = MCI_AMP_ITEM_BASE+9;
  MCI_AMP_STATUS_ALC            = MCI_AMP_ITEM_BASE+10;
  MCI_AMP_STATUS_CHORUS         = MCI_AMP_ITEM_BASE+11;
  MCI_AMP_STATUS_CUSTOM1        = MCI_AMP_ITEM_BASE+12;
  MCI_AMP_STATUS_CUSTOM2        = MCI_AMP_ITEM_BASE+13;
  MCI_AMP_STATUS_CUSTOM3        = MCI_AMP_ITEM_BASE+14;

  // MCI_STATUS item values for cd audio
  MCI_CD_STATUS_TRACK_TYPE      = MCI_CD_ITEM_BASE;
  MCI_CD_STATUS_TRACK_COPYPERMITTED = MCI_CD_ITEM_BASE+1;
  MCI_CD_STATUS_TRACK_CHANNELS  = MCI_CD_ITEM_BASE+2;
  MCI_CD_STATUS_TRACK_PREEMPHASIS = MCI_CD_ITEM_BASE+3;

  // return values for CD MCI_STATUS message with
  //   MCI_CD_STATUS_TRACK_TYPE set
  MCI_CD_TRACK_AUDIO            = $00000001;
  MCI_CD_TRACK_DATA             = $00000002;
  MCI_CD_TRACK_OTHER            = $00000003;

  // MCI_STATUS item values for CDXA
  MCI_CDXA_STATUS_CHANNEL       = MCI_CDXA_ITEM_BASE;

  //returned from call for MCI_CDXA_STATUS_CHANNEL
  MCI_CDXA_NONE                 = $00000000;

  // MCI_STATUS item values for sequencer
  MCI_SEQ_STATUS_TEMPO          = MCI_SEQ_ITEM_BASE;
  MCI_SEQ_STATUS_OFFSET         = MCI_SEQ_ITEM_BASE+1;
  MCI_SEQ_STATUS_DIVTYPE        = MCI_SEQ_ITEM_BASE+2;
  MCI_SEQ_STATUS_MASTER         = MCI_SEQ_ITEM_BASE+3;
  MCI_SEQ_STATUS_PORT           = MCI_SEQ_ITEM_BASE+4;
  MCI_SEQ_STATUS_SLAVE          = MCI_SEQ_ITEM_BASE+5;

  // Return value for current division type
  MCI_SEQ_DIV_PPQN              = $00000001;
  MCI_SEQ_DIV_SMPTE_24          = $00000002;
  MCI_SEQ_DIV_SMPTE_25          = $00000003;
  MCI_SEQ_DIV_SMPTE_30DROP      = $00000004;
  MCI_SEQ_DIV_SMPTE_30          = $00000005;

  // MCI_STATUS items for videodisc
  MCI_VD_STATUS_SPEED           = MCI_VD_ITEM_BASE;
  MCI_VD_STATUS_FORWARD         = MCI_VD_ITEM_BASE+1;
  MCI_VD_MEDIA_TYPE             = MCI_VD_ITEM_BASE+2;
  MCI_VD_STATUS_SIDE            = MCI_VD_ITEM_BASE+3;
  MCI_VD_STATUS_DISC_SIZE       = MCI_VD_ITEM_BASE+4;

  // Return values for videodisc status command
  MCI_VD_SPEED_NORMAL           = $00000000;
  MCI_VD_SPEED_FAST             = $00000001;
  MCI_VD_SPEED_SLOW             = $00000002;

  // MCI_STATUS items for wave audio
  MCI_WAVE_STATUS_LEVEL         = MCI_WAVE_ITEM_BASE;
  MCI_WAVE_STATUS_SAMPLESPERSEC = MCI_WAVE_ITEM_BASE+1;
  MCI_WAVE_STATUS_AVGBYTESPERSEC = MCI_WAVE_ITEM_BASE+2;
  MCI_WAVE_STATUS_BLOCKALIGN    = MCI_WAVE_ITEM_BASE+3;
  MCI_WAVE_STATUS_FORMATTAG     = MCI_WAVE_ITEM_BASE+4;
  MCI_WAVE_STATUS_CHANNELS      = MCI_WAVE_ITEM_BASE+5;
  MCI_WAVE_STATUS_BITSPERSAMPLE = MCI_WAVE_ITEM_BASE+6;

  // Common video MCI_STATUS items
  MCI_VID_STATUS_hwnd                          = MCI_VID_ITEM_BASE;
  MCI_VID_STATUS_AUDIO_COMPRESSION             = MCI_VID_ITEM_BASE+1;
  MCI_VID_STATUS_VIDEO_COMPRESSION             = MCI_VID_ITEM_BASE+2;
  MCI_VID_STATUS_IMAGE_COMPRESSION             = MCI_VID_ITEM_BASE+3;
  MCI_VID_STATUS_AUDIO_QUALITY                 = MCI_VID_ITEM_BASE+4;
  MCI_VID_STATUS_VIDEO_QUALITY                 = MCI_VID_ITEM_BASE+5;
  MCI_VID_STATUS_IMAGE_QUALITY                 = MCI_VID_ITEM_BASE+6;
  MCI_VID_STATUS_IMAGE_BITSPERPEL              = MCI_VID_ITEM_BASE+7;
  MCI_VID_STATUS_IMAGE_PELFORMAT               = MCI_VID_ITEM_BASE+8;
  MCI_VID_STATUS_FORWARD                       = MCI_VID_ITEM_BASE+9;
  MCI_VID_STATUS_NORMAL_RATE                   = MCI_VID_ITEM_BASE+10;
  MCI_VID_STATUS_VIDEO_X_EXTENT                = MCI_VID_ITEM_BASE+11;
  MCI_VID_STATUS_VIDEO_Y_EXTENT                = MCI_VID_ITEM_BASE+12;
  MCI_VID_STATUS_IMAGE_X_EXTENT                = MCI_VID_ITEM_BASE+13;
  MCI_VID_STATUS_IMAGE_Y_EXTENT                = MCI_VID_ITEM_BASE+14;
  MCI_VID_STATUS_BRIGHTNESS                    = MCI_VID_ITEM_BASE+15;
  MCI_VID_STATUS_CONTRAST                      = MCI_VID_ITEM_BASE+16;
  MCI_VID_STATUS_HUE                           = MCI_VID_ITEM_BASE+17;
  MCI_VID_STATUS_SATURATION                    = MCI_VID_ITEM_BASE+18;
  MCI_VID_STATUS_GREYSCALE                     = MCI_VID_ITEM_BASE+19;
  MCI_VID_STATUS_SHARPNESS                     = MCI_VID_ITEM_BASE+20;
  MCI_VID_STATUS_SPEED                         = MCI_VID_ITEM_BASE+21;
  MCI_VID_STATUS_IMAGE_FILE_FORMAT             = MCI_VID_ITEM_BASE+22;
  MCI_VID_STATUS_TRANSPARENT_TYPE              = MCI_VID_ITEM_BASE+23;
  MCI_VID_STATUS_REF_INTERVAL                  = MCI_VID_ITEM_BASE+24;
  MCI_VID_STATUS_MAXDATARATE                   = MCI_VID_ITEM_BASE+25;
  MCI_VID_STATUS_VIDEO_FILE_FORMAT             = MCI_VID_ITEM_BASE+26;

  // Status Transparent Type returns
  // MCI_VID_PALETTE
  // MCI_VID_RGB
  // MCI_VID_YUV
  MCI_VID_STATUS_TRANSPARENT_COLOR             = MCI_VID_ITEM_BASE+24;

  // MCI_STATUS items for digital video
  MCI_DGV_STATUS_hwnd                          = MCI_VID_STATUS_hwnd;
  MCI_DGV_STATUS_AUDIO_COMPRESSION             = MCI_VID_STATUS_AUDIO_COMPRESSION;
  MCI_DGV_STATUS_VIDEO_COMPRESSION             = MCI_VID_STATUS_VIDEO_COMPRESSION;
  MCI_DGV_STATUS_IMAGE_COMPRESSION             = MCI_VID_STATUS_IMAGE_COMPRESSION;
  MCI_DGV_STATUS_AUDIO_QUALITY                 = MCI_VID_STATUS_AUDIO_QUALITY;
  MCI_DGV_STATUS_VIDEO_QUALITY                 = MCI_VID_STATUS_VIDEO_QUALITY;
  MCI_DGV_STATUS_IMAGE_QUALITY                 = MCI_VID_STATUS_IMAGE_QUALITY;
  MCI_DGV_STATUS_IMAGE_BITSPERPEL              = MCI_VID_STATUS_IMAGE_BITSPERPEL;
  MCI_DGV_STATUS_IMAGE_PELFORMAT               = MCI_VID_STATUS_IMAGE_PELFORMAT;
  MCI_DGV_STATUS_FORWARD                       = MCI_VID_STATUS_FORWARD;
  MCI_DGV_STATUS_NORMAL_RATE                   = MCI_VID_STATUS_NORMAL_RATE;
  MCI_DGV_STATUS_VIDEO_X_EXTENT                = MCI_VID_STATUS_VIDEO_X_EXTENT;
  MCI_DGV_STATUS_VIDEO_Y_EXTENT                = MCI_VID_STATUS_VIDEO_Y_EXTENT;
  MCI_DGV_STATUS_IMAGE_X_EXTENT                = MCI_VID_STATUS_IMAGE_X_EXTENT;
  MCI_DGV_STATUS_IMAGE_Y_EXTENT                = MCI_VID_STATUS_IMAGE_Y_EXTENT;
  MCI_DGV_STATUS_BRIGHTNESS                    = MCI_VID_STATUS_BRIGHTNESS;
  MCI_DGV_STATUS_CONTRAST                      = MCI_VID_STATUS_CONTRAST;
  MCI_DGV_STATUS_HUE                           = MCI_VID_STATUS_HUE;
  MCI_DGV_STATUS_SATURATION                    = MCI_VID_STATUS_SATURATION;
  MCI_DGV_STATUS_SPEED                         = MCI_VID_STATUS_SPEED;
  MCI_DGV_STATUS_SHARPNESS                     = MCI_VID_STATUS_SHARPNESS;
  MCI_DGV_STATUS_REF_INTERVAL                  = MCI_VID_STATUS_REF_INTERVAL;
  MCI_DGV_STATUS_MAXDATARATE                   = MCI_VID_STATUS_MAXDATARATE;
  MCI_DGV_STATUS_VIDEO_FILE_FORMAT             = MCI_VID_STATUS_VIDEO_FILE_FORMAT;

  MCI_DGV_STATUS_CHANNELS                      = MCI_DGV_ITEM_BASE+13;
  MCI_DGV_STATUS_BITSPERSAMPLE                 = MCI_DGV_ITEM_BASE+14;
  MCI_DGV_STATUS_SAMPLESPERSEC                 = MCI_DGV_ITEM_BASE+15;
  MCI_DGV_STATUS_FORMATTAG                     = MCI_DGV_ITEM_BASE+16;
  MCI_DGV_STATUS_BLOCKALIGN                    = MCI_DGV_ITEM_BASE+17;
  MCI_DGV_STATUS_AVGBYTESPERSEC                = MCI_DGV_ITEM_BASE+18;
  MCI_DGV_STATUS_VIDEO_COMPRESSION_SUBTYPE     = MCI_DGV_ITEM_BASE+19;
  MCI_DGV_STATUS_VIDEO_RECORD_RATE             = MCI_DGV_ITEM_BASE+20;
  MCI_DGV_STATUS_VIDEO_RECORD_FRAME_DURATION   = MCI_DGV_ITEM_BASE+21;
  MCI_DGV_STATUS_RECORD_AUDIO                  = MCI_DGV_ITEM_BASE+22;
  MCI_DGV_STATUS_TRANSPARENT_COLOR             = MCI_DGV_ITEM_BASE+23;
  MCI_DGV_STATUS_GRAPHIC_TRANSPARENT_COLOR     = MCI_DGV_ITEM_BASE+23;  // MUST BE SAME AS TRANSPARENT COLOR
  MCI_DGV_STATUS_hwnd_MONITOR                  = MCI_DGV_ITEM_BASE+24;
  MCI_DGV_STATUS_DROPPED_FRAME_PCT             = MCI_DGV_ITEM_BASE+25;
  MCI_DGV_STATUS_AUDIOSYNC                     = MCI_DGV_ITEM_BASE+26;
  MCI_DGV_STATUS_AUDIOSYNC_DIRECTION           = MCI_DGV_ITEM_BASE+27;
  MCI_DGV_STATUS_VIDEO_TRANSPARENT_COLOR       = MCI_DGV_ITEM_BASE+28;  // MUST BE SAME AS TRANSPARENT COLOR
  MCI_DGV_STATUS_TUNER_TV_CHANNEL              = MCI_DGV_ITEM_BASE+29;
  MCI_DGV_STATUS_TUNER_LOW_TV_CHANNEL          = MCI_DGV_ITEM_BASE+29;
  MCI_DGV_STATUS_TUNER_HIGH_TV_CHANNEL         = MCI_DGV_ITEM_BASE+29;
  MCI_DGV_STATUS_TUNER_REGION                  = MCI_DGV_ITEM_BASE+30;
  MCI_DGV_STATUS_TUNER_FINETUNE                = MCI_DGV_ITEM_BASE+31;
  MCI_DGV_STATUS_TUNER_FREQUENCY               = MCI_DGV_ITEM_BASE+32;
  MCI_DGV_STATUS_TUNER_AUDIO_CHANNEL           = MCI_DGV_ITEM_BASE+33;
  MCI_DGV_STATUS_TUNER_AFC                     = MCI_DGV_ITEM_BASE+34;
  MCI_DGV_STATUS_VALID_SIGNAL                  = MCI_DGV_ITEM_BASE+35;

  // MCI_STATUS item values for video overlay
  MCI_OVLY_STATUS_hwnd                         = MCI_VID_STATUS_hwnd;
  MCI_OVLY_STATUS_IMAGE_COMPRESSION            = MCI_VID_STATUS_IMAGE_COMPRESSION;
  MCI_OVLY_STATUS_IMAGE_BITSPERPEL             = MCI_VID_STATUS_IMAGE_BITSPERPEL;
  MCI_OVLY_STATUS_IMAGE_PELFORMAT              = MCI_VID_STATUS_IMAGE_PELFORMAT;
  MCI_OVLY_STATUS_IMAGE_X_EXTENT               = MCI_VID_STATUS_IMAGE_X_EXTENT;
  MCI_OVLY_STATUS_IMAGE_Y_EXTENT               = MCI_VID_STATUS_IMAGE_Y_EXTENT;
  MCI_OVLY_STATUS_BRIGHTNESS                   = MCI_VID_STATUS_BRIGHTNESS;
  MCI_OVLY_STATUS_CONTRAST                     = MCI_VID_STATUS_CONTRAST;
  MCI_OVLY_STATUS_HUE                          = MCI_VID_STATUS_HUE;
  MCI_OVLY_STATUS_SATURATION                   = MCI_VID_STATUS_SATURATION;
  MCI_OVLY_STATUS_GREYSCALE                    = MCI_VID_STATUS_GREYSCALE;
  MCI_OVLY_STATUS_IMAGE_QUALITY                = MCI_VID_STATUS_IMAGE_QUALITY;
  MCI_OVLY_STATUS_SHARPNESS                    = MCI_VID_STATUS_SHARPNESS;
  MCI_OVLY_STATUS_IMAGE_FILE_FORMAT            = MCI_VID_STATUS_IMAGE_FILE_FORMAT;
  MCI_OVLY_STATUS_TRANSPARENT_TYPE             = MCI_VID_STATUS_TRANSPARENT_TYPE;
  MCI_OVLY_STATUS_TRANSPARENT_COLOR            = MCI_VID_STATUS_TRANSPARENT_COLOR;

  // Status Mode return values
  MCI_MODE_NOT_READY            = $00000001;
  MCI_MODE_PAUSE                = $00000002;
  MCI_MODE_PLAY                 = $00000003;
  MCI_MODE_STOP                 = $00000004;
  MCI_MODE_RECORD               = $00000005;
  MCI_MODE_SEEK                 = $00000006;

  // Status Direction return values
  MCI_FORWARD                   = $00000000;
  MCI_REVERSE                   = $00000001;

type
  mci_Status_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulReturn                    : uLong;       // Return field
    ulItem                      : uLong;       // Item field for STATUS item to query
    ulValue                     : uLong;       // Status value field (this used to be)
                                               //  ulTrack but was changed in Rel 1.1
                                               //  to extend the status structure.
                                               //  See the programming reference on when
                                               //  ulValue is used and how...
  end;
  pmci_Status_Parms = ^mci_Status_Parms;

  mci_CDXA_Status_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulReturn                    : uLong;       // Return field
    ulItem                      : uLong;       // Item field for STATUS item to query
    ulValue                     : uLong;       // Status value field (this used to be)
                                               //  ulTrack but was changed in Rel 1.1
                                               //  to extend the status structure.
                                               //  See the programming reference on when
                                               //  ulValue is used and how...
    ulChannel                   : uLong;       // Channel
  end;
  pmci_CDXA_Status_Parms = ^mci_CDXA_Status_Parms;

const
  // flags and parameter structure for the MCI_STEP message
  //     $0000$00 are reserved for MCI_STEP flags
  MCI_STEP_FRAMES               = $00000100;
  MCI_STEP_REVERSE              = $00000200;

type
  mci_Step_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulStep                      : uLong;       // amount to step in current time format
  end;
  pmci_Step_Parms = ^mci_Step_Parms;

const
  // Flags for the MCI_SYSINFO message
  //     $XXXXXX00 are reserved for MCI_SYSINFO flags
  MCI_SYSINFO_QUANTITY          = $00000100;
  MCI_SYSINFO_OPEN              = $00000200;
  MCI_SYSINFO_NAME              = $00000400;
  MCI_SYSINFO_INSTALLNAME       = $00000800;
  MCI_SYSINFO_ITEM              = $00001000;
  MCI_SYSINFO_INI_LOCK          = $00002000;

  // Extended SYSINFO functions
  MCI_SYSINFO_INSTALL_DRIVER    = $00000001;
  MCI_SYSINFO_QUERY_DRIVER      = $00000002;
  MCI_SYSINFO_DELETE_DRIVER     = $00000004;
  MCI_SYSINFO_SET_PARAMS        = $00000008;
  MCI_SYSINFO_QUERY_PARAMS      = $00000010;
  MCI_SYSINFO_SET_CONNECTORS    = $00000020;
  MCI_SYSINFO_QUERY_CONNECTORS  = $00000040;
  MCI_SYSINFO_SET_EXTENSIONS    = $00000080;
  MCI_SYSINFO_QUERY_EXTENSIONS  = $00000100;
  MCI_SYSINFO_SET_ALIAS         = $00000200;
  MCI_SYSINFO_QUERY_NAMES       = $00000400;
  MCI_SYSINFO_SET_DEFAULT       = $00000800;
  MCI_SYSINFO_QUERY_DEFAULT     = $00001000;
  MCI_SYSINFO_SET_TYPES         = $00002000;
  MCI_SYSINFO_QUERY_TYPES       = $00004000;

  // Device Flags
  MCI_SYSINFO_DEV_CONTROLLABLE  = $00000001;
  MCI_SYSINFO_DEV_NONCONTROLLABLE = $00000002;
  MCI_SYSINFO_DEVICESETTINGS    = $00000004;

type
  MaxDevNameChar = array [0..Max_Device_Name-1] of CHAR;
  MaxVerNumChar = array [0..Max_Version_Number-1] of CHAR;
  MaxProdInfChar = array [0..Max_ProdInfo-1] of CHAR;
  MaxPddNameChar = array [0..Max_Pdd_Name-1] of CHAR;
  MaxClsShort    = array [0..Max_Classes-1] of uShort;
  MaxClsShort2   = array [0..Max_Classes-1,0..Max_Classes-1] of uShort;
  MaxDevParmChar = array [0..Max_Dev_Params-1] of CHAR;
  // Parameter structures for the MCI_SYSINFO message
  mci_SysInfo_Parms = record
    hwndDummyCallback        : hwnd;           // NOTIFY not allowed for SYSINFO
    pszReturn                : pChar;          // Pointer to return buffer
    ulRetSize                : uLong;          // Return buffer size
    ulNumber                 : uLong;          // Ordinal Number
    usDeviceType             : uShort;         // MCI device type number
    usReserved0              : uShort;         // Reserved field
    ulItem                   : uLong;          // Used to indicate the MCI_SYSINFO
    pSysInfoParm             : Pointer;        // extended function to perform
  end;
  pmci_SysInfo_Parms = ^mci_SysInfo_Parms;

  mci_SysInfo_LogDevice = record
    szInstallName            : MaxDevNameChar; // Device install name
    usDeviceType             : uShort;         // Device type number
    ulDeviceFlag             : uLong;          // Flag indicating whether device
                                               //  device is controllable or not
    szVersionNumber          : MaxVerNumChar;  // INI file version number
    szProductInfo            : MaxProdInfChar; // Textual product description
    szMCDDriver              : MaxDevNameChar; // MCI Driver dll name
    szVSDDriver              : MaxDevNameChar; // VSD dll name
    szPDDName                : MaxPddNameChar; // Device PDD name
    szMCDTable               : MaxDevNameChar; // Device type command table
    szVSDTable               : MaxDevNameChar; // Device specific command table
    usShareType              : uShort;         // Device sharing mode
    szResourceName           : MaxDevNameChar; // Resource name
    usResourceUnits          : uShort;         // Total resource units available
                                               //  for this device
    usResourceClasses        : uShort;         // Number of resource classes for
                                               //  this device
    ausClassArray            : MaxClsShort;    // Maximum number of resource
                                               //  units for each class
    ausValidClassArray       : MaxClsShort2;   // Valid class combinations
  end;
  pmci_SysInfo_LogDevice = ^mci_SysInfo_LogDevice;

  mci_SysInfo_DevParams = record
    szInstallName            : MaxDevNameChar; // Device install name
    szDevParams              : MaxDevParmChar; // Device specific parameters
  end;
  pmci_SysInfo_DevParams = ^mci_SysInfo_DevParams;

type
  Connect = record
    usConnectType            : uShort;         // Connector type
    szToInstallName          : MaxDevNameChar; // Install name this connector
                                               //  is connected to
    usToConnectIndex         : uShort;         // Connector index this connector
                                               //  is connected to
  end;
  pConnect = ^Connect;

  MaxCnctCnct      = array[0..MAX_CONNECTORS-1] of Connect;
  MaxExtChar2      = array[0..MAX_EXTENSIONS-1,0..MAX_EXTENSION_NAME-1] of CHAR;
  MaxAliasNameChar = array[0..Max_Alias_Name-1] of Char;
  MaxTypeBufChar   = array[0..Max_TypeBuffer] of Char;

  mci_SysInfo_ConParams = record
    szInstallName            : MaxDevNameChar; // Device install name
    usNumConnectors          : uShort;         // Number of device connectors
    ConnectorList            : MaxCnctCnct;    // Connector list array
  end;
  pmci_SysInfo_ConParams = ^mci_SysInfo_ConParams;

  mci_SysInfo_Extension = record
    szInstallName            : MaxDevNameChar; // Device install name
    usNumExtensions          : uShort;         // Number of extensions
    szExtension              : MaxExtChar2;    // Extension name array
  end;
  pmci_SysInfo_Extension = ^mci_SysInfo_Extension;

  mci_SysInfo_Alias = record
    szInstallName            : MaxDevNameChar;   // Device install name
    szAliasName              : MaxAliasNameChar; // Alias name
  end;
  pmci_SysInfo_Alias = ^mci_SysInfo_Alias;

  mci_SysInfo_DefaultDevice = record
    szInstallName            : MaxDevNameChar; // Device install name
    usDeviceType             : uShort;         // Device type number
  end;
  pmci_SysInfo_DefaultDevice = ^mci_SysInfo_DefaultDevice;

  mci_SysInfo_Query_Name = record
    szInstallName            : MaxDevNameChar; // Device install name
    szLogicalName            : MaxDevNameChar; // Logical device name
    szAliasName              : MaxAliasNameChar; // Alias name
    usDeviceType             : uShort;         // Device type number
    usDeviceOrd              : uShort;         // Device type ordinal
  end;
  pmci_SysInfo_Query_Name = ^mci_SysInfo_Query_Name;

  mci_SysInfo_Types = record
    szInstallName            : MaxDevNameChar; // Device install name
    szTypes                  : MaxTypeBufChar; // EA types
  end;
  pmci_SysInfo_Types = ^mci_SysInfo_Types;


const
  // Flags for the MCI_UNFREEZE message
  //     $0000$00 are reserved for MCI_UNFREEZE flags
  MCI_OVLY_UNFREEZE_RECT         = $00000100;
  MCI_OVLY_UNFREEZE_RECT_OUTSIDE = $00000200;

  // Flags for the MCI_WHERE message
  //     $000$X00 are reserved for MCI_WHERE flags
  MCI_VID_WHERE_DESTINATION     = $00000100;
  MCI_VID_WHERE_SOURCE          = $00000200;
  MCI_VID_WHERE_WINDOW          = $00000400;

  MCI_DGV_WHERE_DESTINATION     = MCI_VID_WHERE_DESTINATION;
  MCI_DGV_WHERE_SOURCE          = MCI_VID_WHERE_SOURCE;
  MCI_DGV_WHERE_WINDOW          = MCI_VID_WHERE_WINDOW;
  MCI_DGV_WHERE_ADJUSTED        = $00000800;

  MCI_OVLY_WHERE_DESTINATION    = MCI_VID_WHERE_DESTINATION;
  MCI_OVLY_WHERE_SOURCE         = MCI_VID_WHERE_SOURCE;
  MCI_OVLY_WHERE_WINDOW         = MCI_VID_WHERE_WINDOW;

  // Flags and parameter structure for the MCI_WINDOW message
  //     $000$X00   are reserved for MCI_WINDOW flags
  MCI_VID_WINDOW_hwnd           = $00000100;
  MCI_VID_WINDOW_STATE          = $00000200;
  MCI_VID_WINDOW_TEXT           = $00000400;
  MCI_VID_WINDOW_DEFAULT        = $00000800;

  MCI_DGV_WINDOW_hwnd           = MCI_VID_WINDOW_hwnd;
  MCI_DGV_WINDOW_STATE          = MCI_VID_WINDOW_STATE;
  MCI_DGV_WINDOW_TEXT           = MCI_VID_WINDOW_TEXT;
  MCI_DGV_WINDOW_DEFAULT        = MCI_VID_WINDOW_DEFAULT;

  MCI_OVLY_WINDOW_hwnd          = MCI_VID_WINDOW_hwnd;
  MCI_OVLY_WINDOW_STATE         = MCI_VID_WINDOW_STATE;
  MCI_OVLY_WINDOW_TEXT          = MCI_VID_WINDOW_TEXT;
  MCI_OVLY_WINDOW_DEFAULT       = MCI_VID_WINDOW_DEFAULT;

type
  mci_Vid_Window_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    hwndDest                    : hwnd;        // Handle to the client window used for
                                               // the destination of the video image
    usCmdShow                   : uShort;      // Specifies how the window is displayed
    usReserved1                 : uShort;      // Reserved
    pszText                     : pChar;       // The text to use as the window caption
    pszAlias                    : pChar;       // The window alias for the display window
  end;
  pmci_Vid_Window_Parms = ^mci_Vid_Window_Parms;

  mci_dgv_Window_Parms = mci_Vid_Window_Parms;
  pmci_dgv_Window_Parms = ^mci_dgv_Window_Parms;

  mci_Ovly_Window_Parms = mci_Vid_Window_Parms;
  pmci_Ovly_Window_Parms = ^mci_Ovly_Window_Parms;

const
  // flags and parameter structure for the MCI_TUNER  message
  MCI_DGV_AUDIO_CHANNEL         = $00010000;
  MCI_DGV_TV_CHANNEL            = $00020000;
  MCI_DGV_FREQUENCY             = $00040000;
  MCI_DGV_FINETUNE_PLUS         = $00080000;
  MCI_DGV_FINETUNE_MINUS        = $00100000;
  MCI_DGV_REGION                = $00200000;
  MCI_DGV_AFC_ON                = $00400000;
  MCI_DGV_AFC_OFF               = $00800000;

type
  mci_Dgv_Tuner_Parms = record
    hwndCallback                : hwnd;        // PM window handle for MCI notify message
    ulFrequency                 : uLong;       // Tuner Frequency
    ulReserved0                 : uLong;       // Reserved 0
    ulTVChannel                 : uLong;       // TV Channel
    lFineTune                   : Long;        // Fine tuning adjustments.
    pszRegion                   : pChar;       // TV Channel Region
    ulReserved1                 : uLong;       // Reserved 1
    ulReserved2                 : uLong;       // Reserved 2
  end;
  pmci_Dgv_Tuner_Parms = ^mci_Dgv_Tuner_Parms;

const
  //  MCI system value defines
  MSV_CLOSEDCAPTION             = $0;
  MSV_MASTERVOLUME              = $1;
  MSV_HEADPHONES                = $2;
  MSV_SPEAKERS                  = $3;
  MSV_WORKPATH                  = $4;
  MSV_SYSQOSVALUE               = $5;
  MSV_SYSQOSERRORFLAG           = $6;

  MSV_MAX                       = $7;

  // Playlist defines
  DATA_OPERATION                = 0;
  BRANCH_OPERATION              = 1;
  LOOP_OPERATION                = 2;
  CALL_OPERATION                = 3;
  RETURN_OPERATION              = 4;
  EXIT_OPERATION                = 5;
  NOP_OPERATION                 = 6;
  MESSAGE_OPERATION             = 7;
  CUEPOINT_OPERATION            = 8;

function mciSendCommand(usDeviceID: uShort; usMessage: uShort; ulParam1: uLong;
         var Param2; usUserParm: uShort): Ulong;

function mciSendString(pszCommandBuf: pChar; pszReturnString: pChar;
         wReturnLength: uShort; hwndCallBack: hwnd; usUserParm: uShort): Ulong;

function mciGetErrorString(ulError: uLong; pszBuffer: pChar; usLength: uShort): Ulong;

function mciMakeGroup(var usDeviceGroupID:uShort; usDeviceCount: uShort;
             var ausDeviceList: uShort; ulFlags: uLong; ulMMTime: uLong): Ulong;

function mciDeleteGroup(usGroupID:uShort): Ulong;

function mciSetSysValue(iSysValue: uShort; var Value): Bool;

function mciQuerySysValue(iSysValue: uShort;var Value): Bool;

function mciGetDeviceID(pszName: pChar): uLong;

{----[ MMDRVOS2 ]----}  // 13k

type
  gID = uShort;

const
  //             MCI Driver  message identifiers
  MCIDRV_SAVE                   = 900;
  MCIDRV_RESTORE                = 901;
  MCIDRV_SYNC                   = 902;
  MCIDRV_CHANGERESOURCE         = 903;
  MCIDRV_CONNECT                = 904;
  MCIDRV_ASSOCIATE              = 905;
  MCIDRV_DISCONNECT             = 906;
  MCIDRV_TEST_CONNECTION        = 907;
  MCIDRV_START                  = 908;
  MCIDRV_SEEK                   = 909;
  MCIDRV_STOP                   = 910;
  MCIDRV_MODIFY_CONNECTION      = 911;
  MCIDRV_INIT_CONNECTION        = 912;
  MCIDRV_DEINIT_CONNECTION      = 913;

  // The following messages are used by the MCIDRV_CONNECT message
  MCIDRV_CONNECT_TARGET         = $00010000;
  MCIDRV_CONNECT_SOURCE         = $00020000;
  MCIDRV_SET_CONNNECTOR_TYPE    = $00040000;
  MCIDRV_CHANGE_SEM             = $00080000;

  // The following messages are used by MCIDRV_START
  MCIDRV_CUE_PLAYBACK           = $00010000;
  MCIDRV_CUE_RECORD             = $00020000;
  MCIDRV_START_PLAYBACK         = $00040000;
  MCIDRV_START_RECORD           = $00080000;
  MCIDRV_START_PREROLL          = $00100000;

  // The following messages are used by MCIDRV_ASSOCIATE
  MCIDRV_OUTPUT                 = $00010000;
  MCIDRV_INPUT                  = $00020000;

  // The following messages are used by MCIDRV_STOP
  MCIDRV_PAUSE_STREAM_NETWORK   = $00010000;
  MCIDRV_FLUSH_STREAM_NETWORK   = $00020000;
  MCIDRV_DISCARD_STREAM_NETWORK = $00040000;

  // The following range of message ID's are reserved for internal use
  //  by MCI drivers
  MCI_INTERNAL_MESSAGES_START   = 1000;
  MCI_INTERNAL_MESSAGES_END     = 1999;

  // Flags used by the string parser for command tables
  MCI_COMMAND_HEAD              = $00000001;
  MCI_END_COMMAND               = $00000002;
  MCI_END_COMMAND_LIST          = $00000003;
  MCI_RETURN                    = $00000004;
  MCI_STRING                    = $00000005;
  MCI_FLAG                      = $00000006;
  MCI_INTEGER                   = $00000007;
  MCI_CONSTANT                  = $00000008;
  MCI_CONSTANT_INTEGER          = $00000009;
  MCI_CONSTANT_STRING           = $0000000A;
  MCI_END_CONSTANT              = $0000000B;
  MCI_DEFAULT_STRING            = $0000000C;
  MCI_DEFAULT_INTEGER           = $0000000D;
  MCI_RETURN_TYPE               = $0000000E;
  MCI_RETURN_TYPE_STRING        = $0000000F;
  MCI_END_RETURN_TYPE           = $00000010;
  MCI_CONSTANT_2                = $00000011;
  MCI_END_CONSTANT_2            = $00000012;
  MCI_CONSTANT_PAIR             = $00000013;
  MCI_END_CONSTANT_PAIR         = $00000014;
  MCI_CONSTANT_INTEGER_PAIR     = $00000015;
  MCI_CONSTANT_STRING_PAIR      = $00000016;
  MCI_RECTL                     = $00000017;
  MCI_CONSTANT_4                = $00000018;
  MCI_END_CONSTANT_4            = $00000019;
  MCI_FOURCC                    = $0000001A;
  MCI_OR                        = $0000001B;
  MCI_END_OR                    = $0000001C;
  MCI_STRING_LIST               = $0000001D;

  // Return types supported by mciSendString
  //   Values $0000 -> $FF00  are reserved by MMPM2
  //   Values $FF01 -> $FFFF  are user definable
  MCI_INTEGER_RETURNED          = $1000;
  MCI_COLONIZED2_RETURN         = $2000;
  MCI_COLONIZED3_RETURN         = $3000;
  MCI_COLONIZED4_RETURN         = $4000;
  MCI_TRUE_FALSE_RETURN         = $5000;
  MCI_ON_OFF_RETURN             = $6000;
  MCI_DEVICENAME_RETURN         = $7000;
  MCI_TIME_FORMAT_RETURN        = $8000;
  MCI_SPEED_FORMAT_RETURN       = $9000;
  MCI_MODE_RETURN               = $A000;
  MCI_MEDIA_TYPE_RETURN         = $B000;
  MCI_TRACK_TYPE_RETURN         = $C000;
  MCI_CONNECTOR_TYPE_RETURN     = $D000;
  MCI_CDXA_CHANNEL_DESTINATION_RETURN = $E000;
  MCI_PREROLL_TYPE_RETURN       = $F000;
  MCI_FORMAT_TAG_RETURN         = $F100;
  MCI_SEQ_SYNCHRONIZATION_RETURN = $F200;
  MCI_VIDEO_QUALITY_RETURN      = $F300;
  MCI_AUDIO_QUALITY_RETURN      = $F400;
  MCI_IMAGE_QUALITY_RETURN      = $F500;
  MCI_VIDEO_COMPRESSION_RETURN  = $F600;
  MCI_AUDIO_COMPRESSION_RETURN  = $F700;
  MCI_IMAGE_COMPRESSION_RETURN  = $F800;
  MCI_RECTL_RETURN              = $F900;
  MCI_FOURCC_RETURN             = $FA00;
  MCI_IMAGE_PELFORMAT_RETURN    = $FB00;
  MCI_DIRECTION_RETURN          = $FC00;
  MCI_SIGNED_INTEGER_RETURN     = $FD00;

  MCI_USER_RETURN               = $FF01;

  // End of msg text used by mciGetErrorString
  MCIERR_MSG_TABLE_END          = MCIERR_BASE + 7000;

  //  MCI DEVICE shareability categories
  FIXEDSINGLECONTEXT            = $0001;
  DYNAMICSINGLECONTEXT          = $0002;
  LIMITEDMULTIPLECONTEXT        = $0003;
  UNLIMITEDMULTIPLECONTEXT      = $0004;

  // MCI driver flag for close during exit list processing
  MCI_CLOSE_EXIT                = $10000000;

  // MCI driver specific error table resource number base
  MMERROR_TABLE_BASE            = 500;

  //  MCIDRV_CHANGERESOURCE  message flags
type
  mciDrv_ChangeResource_Parms = record
    pInstance                   : Pointer;     // pointer to device instance
    usResourceUnits             : uShort;      // required resource units
    usResourceClass             : uShort;      // resource class
    usResourcePriority          : uShort;      // resource priority
  end;
  pmciDrv_ChangeResource_Parms = ^mciDrv_ChangeResource_Parms;

const
  //  MCIDRV_SYNC  message flags
  MCIDRV_SYNC_ENABLE            = $00000100;
  MCIDRV_SYNC_DISABLE           = $00000200;
  MCIDRV_SYNC_REC_PULSE         = $00000400;
  MCIDRV_SYNC_MASTER            = $00000800;
  MCIDRV_SYNC_SET_MASTER        = $00001000;

type
  mciDrv_Sync_Parms = record
    hStreams                    : ^hStream;    // Pointer to list of stream IDs
    ulNumStreams                : uLong;       // number of stream IDs
    mmTime                      : mmTime;      // Sync Pulse Time
    NonStreamMaster             : Bool;        // TRUE if this device can be master
    pevcbSyncPulse              : pSync_evcb;  // pointer to EVCB address (output)
    hidMaster                   : hID;         // Master NULL sh ID (valid only on
                                               //    MCIDRV_SYNC_MASTER
    ulReserved1                 : uLong;       // Reserved field
    ulReserved2                 : uLong;       // Reserved field
  end;
  pmciDrv_Sync_Parms = ^mciDrv_Sync_Parms;

  // Contains information for open message for MCI drivers
  mmDrv_Open_Parms = record
    hwndCallback                : hwnd;        // call back handle
    usDeviceID                  : uShort;      // The device ID assigned to this instance
    usDeviceType                : uShort;      // The device type number
    usDeviceOrd                 : uShort;      // The device ordinal number
    pInstance                   : Pointer;     //  pointer to the instance structure allocated
                                               //  initialized by the driver. The MCI driver
                                               // will fill in this parameter.
    szDevDLLName : Array[0..259] of Char;      // Character string containing the device
                                               // specific DLL name to call for the open.
                                               // (ie. ACPA.DLL)
    pszElementName              : pChar;       //   typically a file name or NULL
    usDevParmLen                : uShort;      // Device parameters data block length.
    pDevParm                    : Pointer;     // Device parameters data block. This data
                                               // block is unique to each type of device.
                                               // (ie. LVD "COM1 9600 N 7 1").
    Reserved0                   : Pointer;
    usResourceUnitsRequired     : uShort;      // number of resource units this instance
                                               // requires.
    usResourceClass             : uShort;      // resource class this instance belongs to
    usResourcePriority          : uShort;      // resource priority for this instance
    ulParam2                    : uLong;       // Pointer to MCI_OPEN structure
  end;
  pmmDrv_Open_Parms = ^mmDrv_Open_Parms;


function mdmDriverNotify( usDeviceID: uShort; wnd: Hwnd; usMsgType: uShort;
                          usUserParm: uShort; ulMsgParm: uLong): uLong;

{----[ MMIOOS2 ]----}

type
  hmmcf = hmmIO;
  FourCC = uLong;
  pFourCC = ^FourCC;
  hPStr = pChar;

// Define MMIO public data structures.
  mmCkInfo = record
    ckid              : FourCC;                // Chunk id (FourCC)
    ckSize            : uLong;                 // Chunk Size (bytes)
    fccType           : FourCC;                // FourCC Type (if ckid RIFF or LIST)
    ulDataOffset      : uLong;                 // File Offset of data portion of chunk
    ulFlags           : uLong;                 // MMIO_DIRTY (if new chunk)
  end;
  pmmCkInfo = ^mmCkInfo;

  mmIOProc = function( pmmIOInfo: Pointer; usMsg: uShort; lp1, lp2: Long): Long;
  pmmIOProc = mmIOProc;
  pCodecProc = mmIOProc;

  mmIOInfo = record
    ulFlags           : uLong;                 // Open flags
    fccIOProc         : FourCC;                // FourCC of the IOProc to use
    pIOProc           : mmIOProc;              // Function Pointer to IOProc to use
    ulErrorRet        : uLong;                 // Extended Error return code
    cchBuffer         : Long;                  // I/O buff size (if used), Fsize if MEM
    pchBuffer         : pChar;                 // Start of I/O buff
    pchNext           : pChar;                 // Next char to read or write in buff
    pchEndRead        : pChar;                 // Last char in buff can be read + 1
    pchEndWrite       : pChar;                 // Last char in buff can be written + 1
    lBufOffset        : Long;                  // Offset in buff to pchNext
    lDiskOffset       : Long;                  // Disk offset in file
    aulInfo           : Array[0..3] of uLong;  // IOProc specific fields
    lLogicalFilePos   : Long;                  // Actual file position, buffered or not
    ulTranslate       : uLong;                 // Translation field
    fccChildIOProc    : FourCC;                // FourCC of Child IOProc
    pExtraInfoStruct  : Pointer;               // Pointer to a structure of related data
    mmio              : hmmIO;                 // Handle to media element
  end;
  pmmIOInfo = ^mmIOInfo;

  mmCfInfo = record
    ulHeaderSize      : uLong;                 // CTOC header size
    ulEntriesTotal    : uLong;                 // Num of CTOC table entries
    ulEntriesDeleted  : uLong;                 // Num of CTOC table entries deleted
    ulEntriesUnused   : uLong;                 // Num of unused CTOC entries
    ulBytesTotal      : uLong;                 // Combined byte size of all CGRP elements
    ulBytesDeleted    : uLong;                 // Byte size of all deleted CGRP elements
    ulHeaderFlags     : uLong;                 // Info about entire compound file (CF)
    usEntrySize       : uShort;                // Size of each CTOC table entry
    usNameSize        : uShort;                // Size of name field in entry, default 13
    usExHdrFields     : uShort;                // Num CTOC header extra fields
    usExEntFields     : uShort;                // Num CTOC entry extra fields
  end;

// Note:  These are variable length uLong arrays that may be present
//        at the end of the MMCFINFO structure.

//   uLong    (*aulExHdrFldUsage)[]   * Array of header extra usage fields
//   uLong    (*aulExtEntFldUsage)[]  * Array of entry extra usage fields
//   uLong    (*aulExHdrField)[]      * Array of header extra fields

  pmmCfInfo = ^mmCfInfo;

  mmCtocEntry = record
    ulOffset          : uLong;                 // Offset of element within CGRP
    ulSize            : uLong;                 // Size of element
    ulMedType         : uLong;                 // Fourcc of element
    ulMedUsage        : uLong;                 // Possible sub type
    ulCompressTech    : uLong;                 // Compression technique used
    ulUncompressBytes : uLong;                 // Actual size of uncompressed element
  end;

// Note:  A variable length name field and possibly a uLong array may
//        be present at the end of the MMCTOCENTRY structure.

//   uLong    (*aulExEntField)[];  * Array of entry extra fields
//   PSZ      pszElementName[];    * Name of element, variable length

  pmmCtocEntry = ^mmCtocEntry;


const
  // Conversion Flags/Data Structures:
  MMIO_MEDIATYPE_IMAGE          = $00000001;  // Image media
  MMIO_MEDIATYPE_AUDIO          = $00000002;  // Audio media
  MMIO_MEDIATYPE_MIDI           = $00000004;  // MIDI media
  MMIO_MEDIATYPE_COMPOUND       = $00000008;  // Cmpd media
  MMIO_MEDIATYPE_OTHER          = $00000010;  // Other media
  MMIO_MEDIATYPE_UNKNOWN        = $00000020;  // Unknown media
  MMIO_MEDIATYPE_DIGITALVIDEO   = $00000040;  // Digital Video
  MMIO_MEDIATYPE_ANIMATION      = $00000080;  // Future: Not Supported
  MMIO_MEDIATYPE_MOVIE          = $00000100;  // Movie File

  MMIO_CANREADTRANSLATED        = $00000001;  //IOProc Cpbilty Flgs
  MMIO_CANWRITETRANSLATED       = $00000002;  // "       "       "
  MMIO_CANREADWRITETRANSLATED   = $00000004;  // "       "       "
  MMIO_CANREADUNTRANSLATED      = $00000008;  // "       "       "
  MMIO_CANWRITEUNTRANSLATED     = $00000010;  // "       "       "
  MMIO_CANREADWRITEUNTRANSLATED = $00000020;  // "       "       "
  MMIO_CANSEEKTRANSLATED        = $00000040;  // "       "       "
  MMIO_CANSEEKUNTRANSLATED      = $00000080;  // "       "       "
  MMIO_CANINSERTUNTRANSLATED    = $00000100;  // "       "       "
  MMIO_CANSAVEUNTRANSLATED      = $00000200;  // "       "       "
  MMIO_CANINSERTTRANSLATED      = $00000400;  // "       "       "
  MMIO_CANSAVETRANSLATED        = $00000800;  // "       "       "
  MMIO_CANMULTITRACKREADTRANSLATED = $00001000; // "       "       "
  MMIO_CANMULTITRACKREADUNTRANSLATED = $00002000; // "       "       "
  MMIO_CANMULTITRACKWRITETRANSLATED = $00004000; // "       "       "
  MMIO_CANMULTITRACKWRITEUNTRANSLATED = $00008000; // "       "       "
  MMIO_CANTRACKSEEKTRANSLATED   = $00010000;  // "       "       "
  MMIO_CANTRACKSEEKUNTRANSLATED = $00020000;  // "       "       "
  MMIO_CANTRACKREADTRANSLATED   = $00040000;  // "       "       "
  MMIO_CANTRACKREADUNTRANSLATED = $00080000;  // "       "       "
  MMIO_CANTRACKWRITETRANSLATED  = $00100000;  // "       "       "
  MMIO_CANTRACKWRITEUNTRANSLATED = $00200000; // "       "       "

  MMIO_IOPROC_STORAGESYSTEM     = $00000001;  // IOProc Types
  MMIO_IOPROC_FILEFORMAT        = $00000002;
  MMIO_IOPROC_DATAFORMAT        = $00000004;

type
  mmFormatInfo = record
    ulStructLen       : uLong;                 // Length of this structure
    fccIOProc         : FourCC;                // IOProc identifier
    ulIOProcType      : uLong;                 // Type of IOProc
    ulMediaType       : uLong;                 // Media Type
    ulFlags           : uLong;                 // IOProc capability flags
    szDefaultFormatExt : Array[0..Sizeof(FourCC)] of Char;
                                               // Default extension 4 + null
    ulCodePage        : uLong;                 // Code Page
    ulLanguage        : uLong;                 // Language
    lNameLength       : Long;                  // length of identifier string
  end;
  pmmFormatInfo = ^mmFormatInfo;

const
  MMIO_IMAGE_UNKNOWN            = $00000000;   // Unknown image content
  MMIO_IMAGE_DRAWING            = $00000001;   // Simple drawing
  MMIO_IMAGE_GRAPH              = $00000002;   // Graphs & Cartoons
  MMIO_IMAGE_PHOTO              = $00000004;   // Varying Color & Shades

  MAX_PALETTE                   = 256;

type
  xdibHdr_Prefix = record
    ulMemSize         : uLong;                 // Length of bitmap
    ulPelFormat       : uLong;
    usTransType       : uShort;
    ulTransVal        : uLong;
  end;

  mmxdibHeader = record                        // XDIB Header
    XDIBHeaderPrefix  : XDIBHDR_PREFIX;
    BMPInfoHeader2    : BITMAPINFOHEADER2;
  end;
  pmmxdibHeader = ^mmxdibHeader;

  mmImageHeader = record
    ulHeaderLength    : uLong;                 // Length in Bytes
    ulContentType     : uLong;                 // Image content
    ulMediaType       : uLong;                 // Media Type
    mmXDIBHeader      : mmXDIBHeader;          // OS/2 2.0 PM compat header
    bmiColors         : Array[0..MAX_PALETTE-1] of RGB2; // PM compatible palette
  end;
  pmmImageHeader = ^mmImageHeader;

const
  MMIO_AUDIO_UNKNOWN            = $00000000;   // Unknown image content
  MMIO_AUDIO_VOICE              = $00000001;   // Limited Range
  MMIO_AUDIO_MUSIC              = $00000002;   // FM Radio or equivalent
  MMIO_AUDIO_HIFI               = $00000004;   // High quality recording

type
  Wave_Header = record
    usFormatTag       : uShort;                // Type of wave format
    usChannels        : uShort;                // Number of channels
    ulSamplesPerSec   : uLong;                 // Sampling rate
    ulAvgBytesPerSec  : uLong;                 // Avg bytes per sec
    usBlockAlign      : uShort;                // Block Alignment in bytes
    usBitsPerSample   : uShort;                // Bits per sample
  end;

  xWav_HeaderInfo = record
    ulAudioLengthInMS      : uLong;            // Audio data in millisecs
    ulAudioLengthInBytes   : uLong;            // Audio data in bytes
    pAdditionalInformation : Pointer;
  end;

  mmxWav_Header = record
    WAVEHeader        : WAVE_HEADER;           // Per RIFF WAVE Definition
    XWAVHeaderInfo    : XWAV_HEADERINFO;       // Extended wave definition
  end;

  mmAudioHeader = record
    ulHeaderLength    : uLong;                 // Length in Bytes
    ulContentType     : uLong;                 // Image content
    ulMediaType       : uLong;                 // Media Type
    mmXWAVHeader      : MMXWAV_HEADER;         // header
  end;
  pmmAudioHeader = ^mmAudioHeader;

const
  MMIO_MIDI_UNKNOWN             = $00000000;  // Unknown midi content
  MMIO_MIDI_VOICE               = $00000001;  // Limited Range
  MMIO_MIDI_MUSIC               = $00000002;  // FM Radio or equivalent
  MMIO_MIDI_HIFI                = $00000004;  // High quality recording

// MMPMMMIO.INI file structure and definitions.

  DLLNAME_SIZE                  = CCHMAXPATH;
  PROCNAME_SIZE                 = 32;

type
  mmIniFileInfo = record
    fccIOProc         : FourCC;                // IOProc identifier
    szDLLName         : Array[0..DLLName_Size-1] of Char;  // DLL name string
    szProcName        : Array[0..ProcName_Size-1] of Char; // Procedure name string
    ulFlags           : uLong;                 // Flags for Preload
    ulExtendLen       : uLong;                 // Length of ext fields
    ulMediaType       : uLong;                 // Media type
    ulIOProcType      : uLong;                 // Type of IOProc
    szDefExt          : Array[0..Max_Extension_Name] of Char;
  end;
  pmmIniFileInfo = ^mmIniFileInfo;

// CODEC Structures and type definitions for Rel. 1.1

const
  CODEC_INFO_SIZE               = 8;
  CODEC_HW_NAME_SIZE            = 32;

type
  CodecIniFileInfo = record
    ulStructLen       : uLong;                 // length of this structure
    fcc               : FourCC;                // File Format ID
    szDLLName         : Array[0..DLLName_Size-1] of Char;       // DLL name string
    szProcName        : Array[0..ProcName_Size-1] of Char;      // Procedure name string
    ulCompressType    : uLong;                 // Compression Type
    ulCompressSubType : uLong;                 // Compression SubType
    ulMediaType       : uLong;                 // Media type
    ulCapsFlags       : uLong;                 // capabilities flags
    ulFlags           : uLong;                 // flags
    szHWID            : Array[0..Codec_HW_Name_Size-1] of Char; // specific information
    ulMaxSrcBufLen    : uLong;                 // max source buffer length
    ulSyncMethod      : uLong;                 // Synchronization method
    fccPreferredFormat: uLong;                 // Preferred output format
    ulXalignment      : uLong;                 // x alignment - video only
    ulYalignment      : uLong;                 // y alignment - video only
    ulSpecInfo        : Array[0..Codec_Info_Size-1] of uLong;   // specific information
  end;
  pCodecIniFileInfo = ^CodecIniFileInfo;

const
  // CODECINIFILEINFO synchronization method (ulSyncMethod) values.
  CODEC_SYNC_METHOD_NO_DROP_FRAMES = 0;
  CODEC_SYNC_METHOD_DROP_FRAMES_IMMEDIATELY = 1;
  CODEC_SYNC_METHOD_DROP_FRAMES_PRECEDING_KEY = 2;
  CODEC_SYNC_METHOD_HARDWARE    = 3;

  // CODECINIFILEINFO capabilities (ulCapsFlags) values.
  CODEC_COMPRESS                = $00000001;
  CODEC_DECOMPRESS              = $00000002;
  CODEC_WINDOW_CLIPPING         = $00000004;
  CODEC_PALETTE_TRANS           = $00000008;
  CODEC_SELFHEAL                = $00000010;
  CODEC_SCALE_PEL_DOUBLE        = $00000020;
  CODEC_SCALE_PEL_HALVED        = $00000040;
  CODEC_SCALE_CONTINUOUS        = $00000080;
  CODEC_MULAPERTURE             = $00000100;
  CODEC_4_BIT_COLOR             = $00000200;
  CODEC_8_BIT_COLOR             = $00000400;
  CODEC_16_BIT_COLOR            = $00000800;
  CODEC_24_BIT_COLOR            = $00001000;
  CODEC_HARDWARE                = $00002000;
  CODEC_SYMMETRIC               = $00004000;
  CODEC_ASYMMETRIC              = $00008000;
  CODEC_DIRECT_DISPLAY          = $00010000;
  CODEC_DEFAULT                 = $00020000;
  CODEC_ORIGIN_LOWERLEFT        = $00040000;
  CODEC_ORIGIN_UPPERLEFT        = $00080000;
  CODEC_SET_QUALITY             = $00100000;  // quality level is settable
  CODEC_DATA_CONSTRAINT         = $00200000;  // data constraint supported
  CODEC_HW_OVERLAY              = $00400000;
  CODEC_MULTI_BUFFER            = $00800000;
  CODEC_DITHER_OUTPUT           = $01000000;

  // Audio related flags
  CODEC_COMP_REALTIME           = $00020000;
  CODEC_DECOMP_REALTIME         = $00040000;

// CODECINIFILEINFO Flag Values (ulFlags) values.

  // Bit definitions for mmioSet()
  MMIO_SET_EXTENDEDINFO         = $0001;
  MMIO_QUERY_EXTENDEDINFO_BASE  = $0002;
  MMIO_QUERY_EXTENDEDINFO_ALL   = $0004;

type
  // CODECASSOC structure
  CodecAssoc = record
   pCodecOpen         : Pointer;               // codec specific open header
   pCODECIniInfo      : PCodecIniFileInfo;     // codecinifileinfo
  end;
  pCodecAssoc = ^CodecAssoc;

  // MMEXTENDINFO structure
  mmExtendInfo = record
    ulStructLen       : uLong;             // length of this structure
    ulBufSize         : uLong;             // total buffer size
    ulFlags           : uLong;             // flags
    ulTrackID         : uLong;             // track ID
    ulNumCODECs       : uLong;             // number of codec entries
    pCODECAssoc       : PCodecAssoc;       // pointer to codec info array
  end;
  pmmExtendInfo = ^mmExtendInfo;

const
  // MMEXTENDINFO operation (ulFlags) values.
  MMIO_TRACK                    = $00000001;
  MMIO_NORMAL_READ              = $00000002;
  MMIO_SCAN_READ                = $00000004;
  MMIO_REVERSE_READ             = $00000008;
  MMIO_CODEC_ASSOC              = $00000100;

// Audio Related defines

  MMIO_REALTIME_CODEC           = $00000200;

  MMIO_RESETTRACKS              = -1;       //  Turns off the active track number.

  CODEC_START                   = $0EC0;
  CODEC_END                     = $0EFF;

  MMIOM_CODEC_CLOSE             = CODEC_START + 1;
  MMIOM_CODEC_OPEN              = CODEC_START + 2;
  MMIOM_CODEC_QUERYNAME         = CODEC_START + 3;
  MMIOM_CODEC_QUERYNAMELENGTH   = CODEC_START + 4;
  MMIOM_CODEC_COMPRESS          = CODEC_START + 5;
  MMIOM_CODEC_DECOMPRESS        = CODEC_START + 6;

// End CODEC include

  // Flags:
  MMIO_CREATE                   = $00000001;       // Open
  MMIO_CTOCFIRST                = $00000002;       // Open
  MMIO_READ                     = $00000004;       // Open
  MMIO_WRITE                    = $00000008;       // Open
  MMIO_READWRITE                = $00000010;       // Open
  MMIO_COMPAT                   = $00000020;       // Open
  MMIO_EXCLUSIVE                = $00000040;       // Open
  MMIO_DENYWRITE                = $00000080;       // Open
  MMIO_DENYREAD                 = $00000100;       // Open
  MMIO_DENYNONE                 = $00000200;       // Open
  MMIO_ALLOCBUF                 = $00000400;       // Open
  MMIO_DELETE                   = $00000800;       // Open

  MMIO_USE_TEMP                 = $00001000;       // Open/Close/Save

  MMIO_INSERTON                 = $00000001;       // Insert
  MMIO_INSERTOFF                = $00000002;       // Insert

  MMIO_RWMODE                   = $00001000;       // Open
  MMIO_SHAREMODE                = $00002000;       // Open

  MMIO_DIRTY                    = $00004000;       // Write

  MMIO_VERTBAR                  = $00008000;       // Open
  MMIO_BUFSHARED                = $00010000;       // Open
  MMIO_APPEND                   = $00020000;       // Open
  MMIO_NOIDENTIFY               = $00040000;       // Open

  MMIO_FINDFIRST                = $00000001;       // CF Find Entry
  MMIO_FINDNEXT                 = $00000002;       // CF Find Entry
  MMIO_FINDUNUSED               = $00000004;       // CF Find Entry
  MMIO_FINDDELETED              = $00000008;       // CF Find Entry

  MMIO_CHANGEDELETED            = $0001;         // CF Change Entry

  MMIO_CF_FQNAME                = $0001;         // CF Compact

  MMIO_FHOPEN                   = $0001;           // Close

  MMIO_EMPTYBUF                 = $0001;           // Flush

  MMIO_CREATERIFF               = $0001;           // CreateChunk
  MMIO_CREATELIST               = $0002;           // CreateChunk
  MMIO_FINDCHUNK                = $0004;           // Descend
  MMIO_FINDRIFF                 = $0008;           // Descend
  MMIO_FINDLIST                 = $0010;           // Descend

  CTOC_HF_SEQUENTIAL            = $00000001;    // CTOC ulHeaderFlags
  CTOC_HF_MEDSUBTYPE            = $00000002;    // CTOC ulHeaderFlags

  CTOC_EFU_UNUSED               = $00000000; // CTOC extra usage code
  CTOC_EFU_LASTMODTIME          = $00000001; // CTOC extra usage code
  CTOC_EFU_CODEPAGE             = $00000002; // CTOC extra usage code
  CTOC_EFU_LANGUAGE             = $00000003; // CTOC extra usage code
  CTOC_EFU_COMPRESSPARAM0       = $00000005; // CTOC extra usage code
  CTOC_EFU_COMPRESSPARAM1       = $00000006; // CTOC extra usage code
  CTOC_EFU_COMPRESSPARAM2       = $00000007; // CTOC extra usage code
  CTOC_EFU_COMPRESSPARAM3       = $00000008; // CTOC extra usage code
  CTOC_EFU_COMPRESSPARAM4       = $00000009; // CTOC extra usage code
  CTOC_EFU_COMPRESSPARAM5       = $0000000A; // CTOC extra usage code
  CTOC_EFU_COMPRESSPARAM6       = $0000000B; // CTOC extra usage code
  CTOC_EFU_COMPRESSPARAM7       = $0000000C; // CTOC extra usage code
  CTOC_EFU_COMPRESSPARAM8       = $0000000D; // CTOC extra usage code
  CTOC_EFU_COMPRESSPARAM9       = $0000000E; // CTOC extra usage code
  CTOC_CharSET_STANDARD         = $00000000; // CTOC charset value

  MMIO_INSTALLPROC              = $00000001; // Install IO Proc
  MMIO_REMOVEPROC               = $00000002; // Install IO Proc
  MMIO_FINDPROC                 = $00000004; // Install IO Proc

  MMIO_MATCHFIRST               = $00000010; // Ini File Handler
  MMIO_MATCHNEXT                = $00000020; // Ini File Handler
  MMIO_MATCHFourCC              = $00000040; // Ini File Handler
  MMIO_MATCHDLL                 = $00000080; // Ini File Handler
  MMIO_MATCHPROCEDURENAME       = $00000100; // Ini File Handler
  MMIO_FULLPATH                 = $00000200; // Ini File Handler
  MMIO_NOVERIFY                 = $00000400; // Ini File Handler
  MMIO_MATCHCOMPRESSTYPE        = $00000800; // Ini File Handler
  MMIO_EXTENDED_STRUCT          = $00001000; // Ini File ulFlags
  MMIO_MATCHCOMPRESSSUBTYPE     = $00002000; // Ini File Handler
  MMIO_MATCHHWID                = $00004000; // Ini File Handler
  MMIO_MATCHCAPSFLAGS           = $00008000; // Ini File Handler
  MMIO_SKIPMATCH                = $00010000; // Ini/Load Handler

  MMIO_TOUPPER                  = $0001;      // StringToFourcc

  MMIO_CF_ENTRY_EXISTS          = $00000001; // Add CGRP element

  MMIO_FORCE_IDENTIFY_SS        = $00000001; // Identify
  MMIO_FORCE_IDENTIFY_FF        = $00000002; // Identify

  MMIO_NOTRANSLATE              = $00000000; // Translation
  MMIO_TRANSLATEDATA            = $00000001; // Translation
  MMIO_TRANSLATEHEADER          = $00000002; // Translation
  MMIO_DECOMPRESS               = $00000004; // CODEC Decompress

  MMIO_DEFAULTBUFFER            = 8192;    // two pages under OS/2 2.0

  MMIO_SEEK_IFRAME              = $00010000;  // Seek to nearest previous IFRAME

  // Messages :
  MMIOM_START                   = $0E00;
  MMIOM_END                     = $0EFF;

  MMIOM_GETCF                   = MMIOM_START + 1;
  MMIOM_GETCFENTRY              = MMIOM_START + 2;

  MMIOM_CLOSE                   = MMIOM_START + 3;
  MMIOM_OPEN                    = MMIOM_START + 4;
  MMIOM_READ                    = MMIOM_START + 5;
  MMIOM_SEEK                    = MMIOM_START + 6;
  MMIOM_WRITE                   = MMIOM_START + 7;

  MMIOM_IDENTIFYFILE            = MMIOM_START + 8;
  MMIOM_GETHEADER               = MMIOM_START + 9;
  MMIOM_SETHEADER               = MMIOM_START + 10;
  MMIOM_QUERYHEADERLENGTH       = MMIOM_START + 11;
  MMIOM_GETFORMATNAME           = MMIOM_START + 12;
  MMIOM_GETFORMATINFO           = MMIOM_START + 13;
  MMIOM_SEEKBYTIME              = MMIOM_START + 14;
  MMIOM_TEMPCHANGE              = MMIOM_START + 15;
  MMIOM_BEGININSERT             = MMIOM_START + 16;
  MMIOM_ENDINSERT               = MMIOM_START + 17;
  MMIOM_SAVE                    = MMIOM_START + 18;
  MMIOM_SET                     = MMIOM_START + 19;
  MMIOM_COMPRESS                = MMIOM_START + 20;
  MMIOM_DECOMPRESS              = MMIOM_START + 21;
  MMIOM_MULTITRACKREAD          = MMIOM_START + 22;
  MMIOM_MULTITRACKWRITE         = MMIOM_START + 23;
  MMIOM_DELETE                  = MMIOM_START + 24;
  MMIOM_BEGINGROUP              = MMIOM_START + 25;
  MMIOM_ENDGROUP                = MMIOM_START + 26;
  MMIOM_UNDO                    = MMIOM_START + 27;
  MMIOM_REDO                    = MMIOM_START + 28;
  MMIOM_BEGINSTREAM             = MMIOM_START + 29;
  MMIOM_ENDSTREAM               = MMIOM_START + 30;


  MMIOM_CUT                     = MMIOM_START + 31;
  MMIOM_COPY                    = MMIOM_START + 32;
  MMIOM_PASTE                   = MMIOM_START + 33;
  MMIOM_CLEAR                   = MMIOM_START + 34;
  MMIOM_STATUS                  = MMIOM_START + 35;
  MMIOM_WINMSG                  = MMIOM_START + 36;
  MMIOM_BEGINRECORD             = MMIOM_START + 37;
  MMIOM_ENDRECORD               = MMIOM_START + 38;


  // These 3 new messages were added with feature 11710
  MMIOM_QUERYIMAGE              = MMIOM_START + 39;
  MMIOM_QUERYIMAGECOUNT         = MMIOM_START + 40;
  MMIOM_SETIMAGE                = MMIOM_START + 41;


  MMIO_REALTIME                 = $00000001;
  MMIO_NONREALTIME              = $00000002;

  MMIOM_USER                    = $0F00;
  MMIOM_USER_END                = $0FFF;

type
  // Parameter structure for MMIOM_STATUS
  mmIO_Status_Parms = record
    hwndWindow        : hwnd;                  // Some items require a window handle
    ulReturn          : uLong;                 // Return field
    ulItem            : uLong;                 // Use MCI_STATUS_... flags here
    ulValue           : uLong;                 // Status value field
    ulType            : uLong;                 // MCI_FORMAT_... of ulReturn
  end;
  pmmIO_Status_Parms = ^mmIO_Status_Parms;

// Parameter structure for MMIOM_COPY, MMIOM_CUT, MMIOM_CLEAR and MMIOM_PASTE

  uSec = Long;                                 // microsecond time format

  mmIO_mEdit_Parms = record
    ulStrucLen        : uLong;                 // length of this structure
    hwndWindow        : hwnd;                  // window handle
    ulStartTime       : uSec;                  // starting time in usec
    ulDuration        : uSec;                  // duration in usec
    ulCurrentFilePosition : uLong;             // current file position in usec
    ulNewFilePosition : uLong;                 // returned by IO proc in usec, MCD will issue a seek
    ulNewFileLength   : uLong;                 // return by IO proc in usec, MCD updates its headers
    pBuffer           : Pointer;               // optional buffer
    ulBufferLength    : uLong;                 // optional buffer's length
    pHeader           : Pointer;               // optional pointer to header for buffer
  end;
  pmmIO_mEdit_Parms = ^mmIO_mEdit_Parms;

  // Parameter structure for MMIOM_WIN_MESSAGE
  mmIO_WinMsg = record
    hwndWindow        : hwnd;                  // these are the parameters
    usMessage         : uShort;                //  ... passed to the
    pParam1           : Pointer;               //  ... window procedure
    pParam2           : Pointer;               //  ... by PM
  end;
  pmmIO_WinMsg = ^mmIO_WinMsg;

const
  // Include error codes for MMIO
  MMIO_SUCCESS                  = 0;
  MMIO_WARNING                  = 2;
  MMIO_ERROR                    = -1;
  MMIOERR_UNSUPPORTED_MESSAGE   = -2;

  MMIO_CF_SUCCESS               = 0;
  MMIO_CF_FAILURE               = 1;

function mmioFourCC( ch0, ch1, ch2, ch3: Char ): uLong; inline;
begin
  Result := ord(ch0) or (ord(ch1) shl 8) or
            (ord(ch2) shl 16) or (ord(ch3) shl 24);
end;

const
  // FourCCs will be initialized in Initialization section
  FourCC_RIFF                   : FourCC = 0;
  FourCC_LIST                   : FourCC = 0;
  FourCC_MEM                    : FourCC = 0;
  FourCC_DOS                    : FourCC = 0;
  FourCC_BND                    : FourCC = 0;
  FourCC_FREE                   : FourCC = 0;
  FourCC_DEL                    : FourCC = 0;
  FourCC_CTOC                   : FourCC = 0;
  FourCC_CGRP                   : FourCC = 0;
  FourCC_CF                     : FourCC = 0;

const
  MMIO_NLS_CharSET_INFO         = 8000;   // RCDATA Name ID for NLS
  MMIO_IOPROC_NAME_TABLE        = 8500;   // RCDATA Name ID for string table
  MMIO_CODEC_NAME_TABLE         = 9000;   // RCDATA Name ID for Codec  table

  // Numeric equivalents of fourcc's.  These are needed for the resource
  // compiler.
  HEX_FourCC_DOS                = $20534f44;
  HEX_FourCC_MEM                = $204d454d;
  HEX_FourCC_BND                = $20444e42;
  HEX_FourCC_CF                 = $20204643;

  // Country codes (CC), languages (LC), and dialects (DC).
  MMIO_DEFAULT_CODE_PAGE        = 437;

  MMIO_CC_NONE                  = 000;
  MMIO_CC_USA                   = 001;
  MMIO_CC_CANADA                = 002;
  MMIO_CC_LATIN_AMERICA         = 003;
  MMIO_CC_GREECE                = 030;
  MMIO_CC_NETHERLANDS           = 031;
  MMIO_CC_BELGIUM               = 032;
  MMIO_CC_FRANCE                = 033;
  MMIO_CC_SPAIN                 = 034;
  MMIO_CC_ITALY                 = 039;
  MMIO_CC_SWITZERLAND           = 041;
  MMIO_CC_AUSTRIA               = 043;
  MMIO_CC_UNITED_KINGDOM        = 044;
  MMIO_CC_DENMARK               = 045;
  MMIO_CC_SWEDEN                = 046;
  MMIO_CC_NORWAY                = 047;
  MMIO_CC_WEST_GERMANY          = 049;
  MMIO_CC_MEXICO                = 052;
  MMIO_CC_BRAZIL                = 055;
  MMIO_CC_AUSTRALIA             = 061;
  MMIO_CC_NEW_ZEALAND           = 064;
  MMIO_CC_JAPAN                 = 081;
  MMIO_CC_KOREA                 = 082;
  MMIO_CC_CHINA                 = 086;
  MMIO_CC_TAIWAN                = 088;
  MMIO_CC_TURKEY                = 090;
  MMIO_CC_PORTUGAL              = 351;
  MMIO_CC_LUXEMBOURG            = 352;
  MMIO_CC_ICELAND               = 354;
  MMIO_CC_FINLAND               = 358;

  MMIO_LC_NONE                  = 0;
  MMIO_DC_NONE                  = 0;
  MMIO_LC_ARABIC                = 1;
  MMIO_DC_ARABIC                = 1;
  MMIO_LC_BULGARIAN             = 2;
  MMIO_DC_BULGARIAN             = 1;
  MMIO_LC_CATALAN               = 3;
  MMIO_DC_CATALAN               = 1;
  MMIO_LC_TRADITIONAL_CHINESE   = 4;
  MMIO_DC_TRADITIONAL_CHINESE   = 1;
  MMIO_LC_SIMPLE_CHINESE        = 4;
  MMIO_DC_SIMPLE_CHINESE        = 2;
  MMIO_LC_CZECH                 = 5;
  MMIO_DC_CZECH                 = 1;
  MMIO_LC_DANISH                = 6;
  MMIO_DC_DANISH                = 1;
  MMIO_LC_GERMAN                = 7;
  MMIO_DC_GERMAN                = 1;
  MMIO_LC_SWISS_GERMAN          = 7;
  MMIO_DC_SWISS_GERMAN          = 2;
  MMIO_LC_GREEK                 = 8;
  MMIO_DC_GREEK                 = 1;
  MMIO_LC_US_ENGLISH            = 9;
  MMIO_DC_US_ENGLISH            = 1;
  MMIO_LC_UK_ENGLISH            = 9;
  MMIO_DC_UK_ENGLISH            = 2;
  MMIO_LC_SPANISH               = 10;
  MMIO_DC_SPANISH               = 1;
  MMIO_LC_SPANISH_MEXICAN       = 10;
  MMIO_DC_SPANISH_MEXICAN       = 2;
  MMIO_LC_FINNISH               = 11;
  MMIO_DC_FINNISH               = 1;
  MMIO_LC_FRENCH                = 12;
  MMIO_DC_FRENCH                = 1;
  MMIO_LC_BELGIAN_FRENCH        = 12;
  MMIO_DC_BELGIAN_FRENCH        = 2;
  MMIO_LC_CANADIAN_FRENCH       = 12;
  MMIO_DC_CANADIAN_FRENCH       = 3;
  MMIO_LC_SWISS_FRENCH          = 12;
  MMIO_DC_SWISS_FRENCH          = 4;
  MMIO_LC_HEBREW                = 13;
  MMIO_DC_HEBREW                = 1;
  MMIO_LC_HUNGARIAN             = 14;
  MMIO_DC_HUNGARIAN             = 1;
  MMIO_LC_ICELANDIC             = 15;
  MMIO_DC_ICELANDIC             = 1;
  MMIO_LC_ITALIAN               = 16;
  MMIO_DC_ITALIAN               = 1;
  MMIO_LC_SWISS_ITALIAN         = 16;
  MMIO_DC_SWISS_ITALIAN         = 2;
  MMIO_LC_JAPANESE              = 17;
  MMIO_DC_JAPANESE              = 1;
  MMIO_LC_KOREAN                = 18;
  MMIO_DC_KOREAN                = 1;
  MMIO_LC_DUTCH                 = 19;
  MMIO_DC_DUTCH                 = 1;
  MMIO_LC_BELGIAN_DUTCH         = 19;
  MMIO_DC_BELGIAN_DUTCH         = 2;
  MMIO_LC_NORWEGIAN_BOKMAL      = 20;
  MMIO_DC_NORWEGIAN_BOKMAL      = 1;
  MMIO_LC_NORWEGIAN_NYNORSK     = 20;
  MMIO_DC_NORWEGIAN_NYNORSK     = 2;
  MMIO_LC_POLISH                = 21;
  MMIO_DC_POLISH                = 1;
  MMIO_LC_BRAZILIAN_PORTUGUESE  = 22;
  MMIO_DC_BRAZILIAN_PORTUGUESE  = 1;
  MMIO_LC_PORTUGUESE            = 22;
  MMIO_DC_PORTUGUESE            = 2;
  MMIO_LC_RHAETO_ROMANIC        = 23;
  MMIO_DC_RHAETO_ROMANIC        = 1;
  MMIO_LC_ROMANIAN              = 24;
  MMIO_DC_ROMANIAN              = 1;
  MMIO_LC_RUSSIAN               = 25;
  MMIO_DC_RUSSIAN               = 1;
  MMIO_LC_SERBO_CROATIAN_LATIN  = 26;
  MMIO_DC_SERBO_CROATIAN_LATIN  = 1;
  MMIO_LC_SERBO_CROATIAN_CYRILLIC = 26;
  MMIO_DC_SERBO_CROATIAN_CYRILLIC = 2;
  MMIO_LC_SLOVAK                = 27;
  MMIO_DC_SLOVAK                = 1;
  MMIO_LC_ALBANIAN              = 28;
  MMIO_DC_ALBANIAN              = 1;
  MMIO_LC_SWEDISH               = 29;
  MMIO_DC_SWEDISH               = 1;
  MMIO_LC_THAI                  = 30;
  MMIO_DC_THAI                  = 1;
  MMIO_LC_TURKISH               = 31;
  MMIO_DC_TURKISH               = 1;
  MMIO_LC_URDU                  = 32;
  MMIO_DC_URDU                  = 1;
  MMIO_LC_BAHASA                = 33;
  MMIO_DC_BAHASA                = 1;

// Base function prototypes:

function mmioAdvance( mmIO: hmmio; Info: pmmioinfo; usFlags: uShort ): uShort;
function mmioAscend( mmIO: hmmio; pckinfo: pmmCkInfo; usFlags: uShort ): uShort;
function mmioClose( mmIO: hmmio; usFlags: uShort ): uShort;
function mmioCreateChunk( mmio: hmmio; pckinfo: pmmCkInfo; usFlags: uShort ): uShort;
function mmioDescend( mmIO: hmmio; pckinfo, pckinfoParent: pMMCkInfo; usFlags: uShort ): uShort;
function mmioFlush( mmIO: hmmio; usFlags: uShort ): uShort;
function mmioGetInfo( mmIO: hmmio; Info: pmmioinfo; usFlags: uShort ): uShort;
function mmioGetLastError( mmIO: hmmio ): uLong;
function mmioInstallIOProc( fccIOProc: FourCC; pIOProc: pMMIOProc; ulFlags: uLong ): pmmIOProc;
function mmioIOProc( mmIOInfo: pMMioInfo; usMsg: uShort; lParam1, lParam2: Long): Long;
function mmioOpen( pszFileName: pChar; mmIOInfo: pmmioinfo; ulOpenFlags: uLong ): hMMIO;
function mmioRead( mmIO: hmmio; pchBuffer: pChar; cBytes: Long ): Long;
function mmioSeek( mmIO: hmmio; lOffset, lOrigin: Long ): Long;
function mmioSendMessage( mmIO: hmmio; usMsg: uShort; lParam1, lParam2: Long ): Long;
function mmioSetBuffer( mmIO: hmmio; pchBuffer: pChar; cBytes: Long; usFlags: uShort ): uShort;
function mmioSetInfo( mmIO: hmmio; mmIOInfo: pmmioinfo; usFlags: uShort ): uSHort;
function mmioStringToFourCC( pszString: pChar; usFlags: uShort ): FourCC;
function mmioWrite( mmIO: hmmio; pchBuffer: pChar; cBytes: Long ): Long;

// Compound File function prototypes:

function mmioCFOpen( pszFileName: pChar; CfInfo, IOInfo: pmmcfinfo; ulFlags: uLong ): hMMCF;
function mmioCFClose( mmCf: hmmcf; ulFlags: uLong ): uLong;
function mmioCFGetInfo( mmCf: hmmcf; CfInfo: pmmcfinfo; cBytes: uLong ): uLong;
function mmioCFSetInfo( mmCf: hmmcf; CfInfo: pmmcfinfo; cBytes: uLong ): uLong;
function mmioCFFindEntry( mmCf: hmmcf; ctocEntry: mmctocentry; ulFlags: uLong ): uLong;
function mmioCFAddEntry( mmCf: hmmcf; cTocEntry: mmctocentry; ulFlags: uLong ): uLong;
function mmioCFChangeEntry( mmCf: hmmcf; CTocEntry: pmmctocentry; ulFlags: uLong ): uLong;
function mmioCFDeleteEntry( mmCf: hmmcf; CTocEntry: pmmctocentry; ulFlags: uLong ): uLong;
function mmioCFAddElement( mmCf: hmmcf; pszElementName: pChar; fccType: FourCC;
  pchBuffer: pChar; cchBytes: Long; ulFlags: uLong ): uLong;

function mmioCFCopy( mmCfSource: hmmcf; pszDestFileName: pChar; ulFlags: uLong ): uLong;

// Conversion Utility function prototypes:

function mmioQueryFormatCount( FormatInfo: pmmformatinfo;
  plNumFormats: pLong; ulReserved: uLong; ulFlags: uLong ): uLong;

function mmioGetFormats( FormatInfo: pmmformatinfo;
  lNumFormats: Long; pFormatInfoList: Pointer; plFormatsRead: pLong;
  ulReserved: uLong; ulFlags: uLong ): uLong;

function mmioGetFormatName( FormatInfo: pmmformatinfo; pszFormatName: pChar;
  plBytesRead: pLong; ulReserved: uLong; ulFlags: uLong ): uLong;

function mmioIdentifyFile( pszFileName: pChar; MMIoInfo: pmmioinfo;
  FormatInfo: pmmformatinfo; pfccStorageSystem: pFourCC; ulReserved: uLong;
  ulFlags: uLong ): uLong;

function mmioQueryHeaderLength( mmIO: hmmio; plHeaderLength: pLong;
  ulReserved: uLong; ulFlags: uLong ): uLong;

function mmioGetHeader( mmIO: hmmio; pHeader: Pointer; lHeaderLength: Long;
  plBytesRead: pLong; ulReserved: uLong; ulFlags: uLong ): uLong;

function mmioSetHeader( mmIO: hmmio; pHeader: Pointer; lHeaderLength: Long;
  plBytesWritten: pLong; ulReserved: uLong; ulFlags: uLong ): uLong;

function mmioIniFileHandler( IniFileInfo: pmminifileinfo; ulFlags: uLong ): uLong;

function mmioIdentifyStorageSystem( pszFileName: pChar;
  MMIoInfo: pmmioinfo; pfccStorageSystem: pFourCC ): uLong;

function mmioDetermineSSIOProc( pszFileName: pChar; MMIoInfo: pmmioinfo;
  pfccStorageSystem: pFourCC; pszParsedRemainder: pChar ): uLong;

function mmioQueryIOProcModuleHandle( IOProc: pMMIOProc;
  IOProcModule: phModule ): uLong;

function mmioCFCompact( pszFileName: pChar; ulFlags: uLong ): uLong;

// MMPMMMIO.INI file migration utility

function mmioMigrateIniFile( ulFlags: uLong ): uLong;

// MMIO CODEC APIs

function mmioIniFileCODEC( IniFile: pCODECIniFileInfo; ulFlags: uLong ): uLong;
function mmioSet( mmIO: hmmio; ExtendInfo: pmmExtendInfo; ulFlags: uLong): uLong;
function mmioQueryCODECName( IniInfo: pCODECIniFileinfo;
  pszCODECName: pChar; pulBytesRead: pUlong ): uLong;

function mmioQueryCODECNameLength( IniInfo: pCODECIniFileinfo;
  pulNameLength: pUlong ): uLong;

function mmioLoadCODECProc( IniInfo: pCODECIniFileInfo;
  Module: phModule; ulFlags: uLong ): pCodecProc;

function mmioGetData( mmIO: hmmio; mmIOInfo: pmmioinfo; usFlags: uShort ): uShort;

{----[ CODEC ]----}

const
  // Ultimotion CODEC type for CODECINIFILEINFO ulCompressType
  FOURCC_ULTI                   : FourCC = 0;
  HEX_FOURCC_ULTI               = $49544C55;    // ITLU

// Indeo CODEC type for CODECINIFILEINFO ulCompressType
  FOURCC_RT21                   : FourCC = 0;
  HEX_FOURCC_RT21               = $31325452;     // 12TR

  // Mondo CODEC type for CODECINIFILEINFO ulCompressType
  FOURCC_DIB                    : FourCC = 0;
  HEX_FOURCC_DIB                = $20424944;     //  BID

type
  // GENPAL - Generic Header Palette
  GenPal = record
    ulStartIndex      : uLong;                 // starting RGB index
    ulNumColors       : uLong;                 // number of following entries
    prgb2Entries      : pRGB2;                 // 256 RGB entries
  end;
  pGenPal = ^GenPal;

  // CODECVIDEOHEADER - CODEC video Header
  CodecVideoHeader = record
    ulStructLen       : uLong;
    cx                : uLong;
    cy                : uLong;
    cPlanes           : uShort;
    cBitCount         : uShort;
    ulColorEncoding   : uLong;
    genpal            : GenPal;
  end;
  pCodecVideoHeader = ^CodecVideoHeader;

const
  // ulColorEncoding defines:
  MMIO_RGB_5_6_5                = $0001;  // Each pixel is a RGB_5_6_5 datatype
  MMIO_RGB_24                   = $0002;  // Each pixel is a RGB_24 datatype
  MMIO_YUV_4_1_1                = $0004;  // Each pixel is a YUV_4_1_1 datatype
  MMIO_COMPRESSED               = $0008;  // The data is compressed
  MMIO_YUV_24                   = $0010;  // Each pixel is a YUV_24 datatype
  MMIO_PALETTIZED               = $0020;  // The data is palettized
  MMIO_OS2_BITMAP24             = $0020;  // The data is palettized


{*********************************************
 *
 * MMVIDEOOPEN - Video Open Structure
 *
 * This structure is passed on the CODEC open
 * message when video compression is being done
 * to indicate information such as quality,
 * frame rate, data rate, and key frame rate.
 *
 * Quality:
 *
 * The ulQuality field specifies a scalar value
 * in the range 0 - 10000, where 0 is the lowest
 * quality and 10000 is the highest quality.  A
 * value of -1 specifies the default quality level,
 * and the default quality level (e.g. 5000) is
 * returned in the ulQuality field.
 *
 *
 * Key Frame rate:
 *
 * The ulKeyFrameRate structure specifies the key
 * frame (aka I-frame, reference frame) frequency.
 * Every Nth frame is a key frame as specified.
 * A value of zero specifies that no periodic key
 * are to be compressed.  Additional key frames may
 * be inserted at any point by specifying
 * MMIO_IS_KEY_FRAME in the MMCOMPRESS structure.
 *
 * example:  ulKeyFrameRate = 5  results in:
 *
 *    key delta delta delta delta key delta delta delta delta key delta...
 *
 *
 * Frame rate:
 *
 * Rate = number of time units per second
 * Scale = number of time units per frame
 *
 * examples:  Rate = 30  Scale = 1     =>    30 FPS
 *            Rate = 15  Scale = 1     =>    15 FPS
 *            Rate = 25  Scale = 2     =>    12.5 FPS
 *
 *
 * Data Constraint:
 *
 * Compressors which are capable of constraining the
 * resultant compressed video data rate use the
 * information in the ulDataConstraint and
 * ulConstraintInterval fields.  A non-zero value
 * in ulDataConstraint specifies the number of bytes
 * which is not to be exceeded over an interval of
 * frames in the output data stream, regardless of
 * the requested quality level.  This value only
 * considers video data, i.e. audio data and file format
 * overhead must be considered seperately when determining
 * the final output file data rate.  The interval of
 * frames over which the data is constrained is specified
 * in ulConstraintInterval.  A value of zero for
 * ulDataContraint specifies that the data rate is not
 * to be constrained and is compressed according to
 * the requested quality level.
 *
 * example 1:  ulDataConstraint = 150000   ulConstraintInterval = 15
 *
 *             This results in an output stream wherein the sizes of any 15
 *             consecutive frames does not exceed 150000 bytes.  If the
 *             frame rate is 15 FPS, the resultant data rate will not
 *             exceed 150000 bytes per second.
 *
 * example 2:  ulDataConstraint = 10000    ulConstraintInterval = 1
 *
 *             This results in an output stream wherein any single frame
 *             does not exceed 10000 bytes.  If the frame rate is 15 FPS,
 *             the resultant data rate will not exceed 150000 bytes per
 *             second.  Note the difference between this case and example 1
 *             where individual frames may exceed 10000 bytes (the average)
 *             so long other frames in any 15 frame sequence are sufficiently
 *             smaller to satisfy the constraint within the constraint interval.
 *
 *********************************************}

type
  mmVideoOpen = record
    ulStructLen          : uLong;
    ulQuality            : uLong;
    ulKeyFrameRate       : uLong;
    ulScale              : uLong;
    ulRate               : uLong;
    ulDataConstraint     : uLong;
    ulConstraintInterval : uLong;
  end;
  pmmVideoOpen = ^mmVideoOpen;

  mmAudioOpen = record
    ulStructLen          : uLong;              // Length of struct
    ulSamplesPerBlock    : uLong;              // Samples in each block of compressed data
    ulBytesPerBlock      : uLong;              // uncompressed bytes in each block
    ulFlags              : uLong;              // Compression flags
    ulBestGuess          : uLong;              // Guess at avg. compression ratio
    ulBlockAlignment     : uLong;              // Block alignment of codec
    ulLength             : uLong;              // Length of the file
    hCodec               : uLong;              // Codec handle
    pfnCodec             : PCODECPROC;
  end;
  pmmAudioOpen = ^mmAudioOpen;

const
  // defines for the ulFlags field of the BUFER_INFORMATION
  BLOCK_ORIENTED                = $00000001;
  NON_LINEAR                    = $00000002;
  INIT_CODEC                    = $00000004;

type
  // CODECOPEN - CODEC open structure
  CodecOpen = record
    ulFlags           : uLong;                 // flags & events - Refer to ulCapsFlags in CODECINIFILEINFO
    pControlHdr       : Pointer;               // control header - (codec specific)
    pSrcHdr           : Pointer;               // source header - Ptr CODECVIDEOHEADER
    pDstHdr           : Pointer;               // destination header - Ptr CODECVIDEOHEADER
    pOtherInfo        : Pointer;               // other information - Ptr MMVIDEOOPEN/MMAUDIOOPEN
  end;
  pCodecOpen = ^CodecOpen;

const
  Valid_CodecOpen_InputFlags = CODEC_DECOMPRESS or
                               CODEC_WINDOW_CLIPPING or
                               CODEC_PALETTE_TRANS or
                               CODEC_SELFHEAL or
                               CODEC_SCALE_PEL_DOUBLE or
                               CODEC_SCALE_PEL_HALVED or
                               CODEC_SCALE_CONTINUOUS or
                               CODEC_MULAPERTURE or
                               CODEC_HARDWARE or
                               CODEC_DIRECT_DISPLAY;

type
  // Stream handler communication
  Audio_Codec_Info = record
    ulStructLen       : uLong;       // Length of struct
    ulBytesPerBlock   : uLong;       // uncompressed bytes in each block
    ulBlockAlignment  : uLong;       // Block alignment of codec
    hCodec            : uLong;       // Codec handle
    pfnCodec          : PCODECPROC;  //  LONG (* APIENTRY pfnCodec) (Pointer, SHORT, LONG, LONG);
  end;

const
  AUDIO_CODEC_INF               = 1000;

type
  // MMCOMPRESS - Compress structure
  mmCompress = record
    ulStructLen       : uLong;                 // length of this structure
    ulFlags           : uLong;                 // command and status flags
    ulSrcBufLen       : uLong;                 // source buffer size
    pSrcBuf           : Pointer;               // source buffer
    ulDstBufLen       : uLong;                 // destination buffer length
    pDstBuf           : Pointer;               // destination buffer
    pRunTimeInfo      : Pointer;               // control information
  end;
  pmmCompress = ^mmCompress;

// ulFlags Input values for MMCOMPRESS structure:
// Note:  MMIO_IS_KEY_FRAME and MMIO_IS_PALETTE are defined
// below, but are listed here for information purposes only.
// MMIO_IS_KEY_FRAME         This bit is set by the application
//                           to instruct the IOProc to compress
//                           the pSrcBuf into a key or reference
//                           frame.  If the bit is not set, a
//                           delta frame is compressed.
// MMIO_IS_PALETTE           A video palette is provided.  This
//                           is set by the application.

type
  // MMVIDEOCOMPRESS - Video Compress structure
  mmVideoCompress = record
    ulStructLen       : uLong;                 // Structure length
    genpalVideo       : GENPAL;                // Video stream palette
    pControlHdr       : Pointer;               // control header (codec specific)
  end;
  pmmVideoCompress = ^mmVideoCompress;

const
  START_DECOMPRESSION           = $00000001;
  CONTINUE_DECOMPRESSION        = $00000002;
  START_SEEK                    = $00000004;
  CONTINUE_SEEK                 = $00000008;

type
  //MMDECOMPRESS - Decompress Structure
  mmDecompress = record
    ulStructLen       : uLong;                 // length of this structure
    ulFlags           : uLong;                 // command and status flags
    ulSrcBufLen       : uLong;                 // source buffer size
    pSrcBuf           : Pointer;               // source buffer
    ulDstBufLen       : uLong;                 // destination buffer length
    pDstBuf           : Pointer;               // destination buffer
    pRunTimeInfo      : Pointer;               // control information Ptr to MMVIDEODECOMPRESS
  end;
  pmmDecompress = ^mmDecompress;

const
  // ulFlags defines:
  MMIO_DROP_DELTA_FRAME         = $0001; // Input/Output - Tells the IOProc to drop the delta
                                         // frame if the pSrcBuf contains a delta
                                         // frame.  On return, the bit is reset
                                         // if the delta frame is dropped.
  MMIO_IS_KEY_FRAME             = $0002; // Output - This bit is set by the IOProc when
                                         // the data contained in the pSrcBuf is
                                         // a key or reference frame.
  MMIO_IS_PALETTE               = $0004; // Output - A video palette has been found.
                                         // This is set by the IOProc.
  MMIO_PALETTE_CHANGE           = $0008; // Input - The physical palette has been changed
                                         // in...  This is set by the application.
  MMIO_ORIGIN_LOWERLEFT         = $0010; // Input - The video frame origin
  MMIO_RECTL_CHANGE             = $0020; // Input - The valid rectl list has changed.
  MMIO_ORIGIN_UPPERLEFT         = $0040; // Input - The video frame origin
  MMIO_DROP_FRAME_DECODE        = $0080; // Input - Tells the IOProc to drop decoding
  MMIO_HIGH_QUALITY             = $0100; // Input - Tells Codec to render best
                                         // quality image - not time critical
  MMIO_IGNORE_CLIPPING          = $0200; // Ignore clipping rectangles used for bitmap capture
                                         // high performance
  MMIO_OUTPUT_FULL_IMAGE        = $0400; // Output a complete image on decompress, even if this
                                         // is a delta frame
                                         // of the frame.

  VALID_DECOMPRESS_INPUTFLAGS   = MMIO_DROP_DELTA_FRAME or
                                  MMIO_PALETTE_CHANGE or
                                  MMIO_ORIGIN_LOWERLEFT or
                                  MMIO_RECTL_CHANGE or
                                  MMIO_DROP_FRAME_DECODE or
                                  MMIO_ORIGIN_UPPERLEFT or
                                  MMIO_HIGH_QUALITY or
                                  MMIO_IGNORE_CLIPPING or
                                  MMIO_OUTPUT_FULL_IMAGE;

  START_COMPRESSION             = $00000001;
  CONTINUE_COMPRESSION          = $00000002;
  SOURCE_UNUSED                 = $00000004;
  TARGET_UNUSED                 = $00000008;

type
  // MMVIDEODECOMPRESS - Video Decompress structure
  mmVideoDeCompress = record
    ulStructLen       : uLong;                 // Structure length
    ulRectlCount      : uLong;                 // Valid rectangle count - for clipping
    prectl            : pRectL;                // Valid rectangle array - for clipping
    ulSkipLength      : uLong;                 // Skipped line length
    ulDecodeLines     : uLong;                 // Num of lines to decompress
    genpalPhysical    : GenPal;                // Physical palette
    genpalVideo       : GenPal;                // Video stream palette
    rectlSrc          : RectL;                 // Source window rectangle
    rectlDst          : RectL;                 // Destination window rectangle
    ulDeltaCount      : uLong;                 // Number of remaining delta frames before the next I-Frame
    ulParm1           : uLong;                 // Codec specific parm
    ulParm2           : uLong;                 // Codec specific parm
    ulParm3           : uLong;                 // Codec specific parm
    ulParm4           : uLong;                 // Codec specific parm
  end;
  pmmVideoDeCompress = ^mmVideoDeCompress;

// RECORDTAB - Record table
// NOTE: This structure maps to ESRCBUFTAB
  RecordTab = record
    ulReserved1       : uLong;                 // reserved for system
    pRecord           : Pointer;               // ptr to record in buffer
    ulLength          : uLong;                 // length of record
    ulReserved2       : uLong;                 // reserved for system
    ulReserved3       : uLong;                 // reserved for system
    ulParm1           : uLong;                 // Record specific data
    ulParm2           : uLong;                 // Record specific data
  end;
  pRecordTab = ^RecordTab;

// RECORDTABWRITE - Record table for video write
// NOTE: This structure maps to ETGTBUFTAB
  RecordTabWrite = record
    pRecord           : Pointer;               // ptr to record in buffer
    ulReserved1       : uLong;                 // reserved for system
    ulLength          : uLong;                 // length of record
    ulReserved2       : uLong;                 // reserved for system
    ulReserved3       : uLong;                 // reserved for system
    ulParm1           : uLong;                 // Record specific data
    ulParm2           : uLong;                 // Record specific data
  end;
  pRecordTabWrite = ^RecordTabWrite;

const
  // ulParm1 Return values for MULTITRACK_READ only:
  // Note:  MMIO_IS_KEY_FRAME and MMIO_IS_PALETTE are defined
  // above, but are listed here for information purposes only
  // as they are valid ulParm1 Return values for MULTITRACK_READ.
  // MMIO_IS_KEY_FRAME         Frame is a Key frame
  // MMIO_IS_PALETTE           Buffer contains a video palette
  MMIO_INVISIBLE_FRAME          = $1000;       // Indicates a invisible video frame
  MMIO_NULL_FRAME               = $2000;       // Indicates a null video frame (zero length)

  // ulParm2 Return values for MULTITRACK_READ only:
  //    This field contains the frame number for this video frame
  //    if this track is a video track.

  // ulParm1 Input values for MULTITRACK_WRITE only:
  // Note:  MMIO_IS_KEY_FRAME and MMIO_IS_PALETTE are defined
  // above, but are listed here for information purposes only
  // as they are valid ulParm1 Input values for MULTITRACK_WRITE.
  // MMIO_IS_KEY_FRAME         Frame is a Key frame
  // MMIO_IS_PALETTE           Buffer contains a video palette

  // ulParm2 Input values for MULTITRACK_WRITE only:
  //    This field contains the number of null frames
  //    that should be inserted before this frame
  //    (this recordtab entry).

type
  // TRACKMAP - This structure maps a track to a record table.
  TrackMap = record
    ulTrackID         : uLong;                 // Input - track ID
    ulNumEntries      : uLong;                 // Input - number of record entries
    pRecordTabList    : pRecordTab;            // Input/Output - Ptr to a record table
  end;
  pTrackMap = ^TrackMap;

  // MMMULTITRACKREAD - Multiple Track Read
  mmMultiTrackRead = record
    ulLength          : uLong;                 // Input - Size of buffer to read.  The IO should be performed on this size of
                                               //          buffer.  The actual buffer size may be bigger and is given in the
                                               //          ulBufferLength field below.  Video frames can span pBuffer+ulLength
                                               //          as long as the frame is less than the ulBufferLength in size.
                                               //          The purpose of this is to break the IO reads into smaller sizes
                                               //          while still allowing large frame sizes.
    pBuffer           : Pointer;               // Input - ptr to read buffer
    ulFlags           : uLong;                 // Input/Output - read flags
    ulNumTracks       : uLong;                 // Input - number of track entries
    pTrackMapList     : pTrackMap;             // Input - ptr to track-to-record list
    ulBufferLength    : uLong;                 // Input - Actual length of read buffer
    ulReserved        : uLong;                 // Input - Reserved (must be 0)
  end;
  pmmMultiTrackRead = ^mmMultiTrackRead;

const
  // ulFlags Input Values:
  MULTITRACKREAD_EXTENDED       = $0004;       // Indicates that the new extended multitrack
                                               // read structure is passed from caller instead
                                               // of the previous multitrack read structure.

  // ulFlags Return Values:
  MULTITRACKREAD_NOTDONE        = $0001;       // Read is not done.  Another read of the same
                                               // buffer is necessary.  There were not enough record
                                               // entries in the record table passed to this api.
  MULTITRACKREAD_EOF            = $0002;       // End of File.  Used because # bytes read may not
                                               // match the length of the buffer in cases of a
                                               // record that spans in the next buffer.

type
  // MMMULTITRACKWRITE - Multiple Track Write
  mmMultiTrackWrite = record
    ulNumTracks       : uLong;                 // Input - number of track entries
    pTrackMapList     : pTrackMap;             // Input - ptr to track-to-record list
    ulFlags           : uLong;                 // Input - write flags (Default = 0)
    ulReserved        : uLong;                 // Input - Reserved (must be 0)
  end;
  pmmMultiTrackWrite = ^mmMultiTrackWrite;

const
  // ulFlags Input Values:
  MULTITRACKWRITE_MERGE         = $0001;       // Attempt to interleave the data on the write.
                                               // The default (without this flag set) is to
                                               // write all records for each track then write
                                               // all records of the next track and so on.

type
  // MMMOVIEHEADER - standard movie header data
  mmMovieHeader = record
    ulStructLen           : uLong;             // length of this structure
    ulContentType         : uLong;             // movie content type
    ulMediaType           : uLong;             // video media type
    ulMovieCapsFlags      : uLong;             // capabilities
    ulMaxBytesPerSec      : uLong;             // maximum transfer rate
    ulPaddingGranularity  : uLong;             // pad to a multiple of this size
    ulSuggestedBufferSize : uLong;
    ulStart               : uLong;             // delay time marking beginning or start of movie
    ulLength              : uLong;
    ulNextTrackID         : uLong;             // next available track id
    ulNumEntries          : uLong;             // number of track entries
    pmmTrackInfoList      : pmmTrackInfo;      // track information
    pszMovieTitle         : pChar;             // movie title
    ulCountry             : uLong;             // country code for the title string
    ulCodePage            : uLong;             // country code page the title string
    ulAvgBytesPerSec      : uLong;             // average transfer rate
  end;
  pmmMovieHeader = ^mmMovieHeader;

const
  // ulMovieCapsFlags Defines:
  MOVIE_HAS_VIDEO               = $0001;       // The movie contains video.
  MOVIE_HAS_AUDIO               = $0002;       // The movie contains audio.
  MOVIE_CAN_SEEK                = $0004;       // The movie can seek.
  MOVIE_CAN_SCAN                = $0008;       // The movie can fast scan.
  MOVIE_HAS_COPYRIGHT           = $0010;       // The movie contains copyrighted data.
  MOVIE_WAS_CAPTUREFILE         = $0020;       // The movie is a specially allocated
                                               // file used for capturing real-time
                                               // video.  Applications should warn
                                               // the user before writing over a file
                                               // with this flag set because the user
                                               // probably defragmented this file.
                                               // If this flag is set, then there is a chance
                                               // that not all of the records will be written
                                               // on the call. Caller must check for this whether
                                               // this flag is set or not.

type
  // MMVIDEOHEADER - Movie Video Track Header
  mmVideoHeader = record
    ulStructLen           : uLong;             // length of this structure
    ulContentType         : uLong;             // video content type
    ulMediaType           : uLong;             // video media type
    ulVideoCapsFlags      : uLong;             // capabilities
    ulWidth               : uLong;             // video width in pels
    ulHeight              : uLong;             // video height in pels
    ulScale               : uLong;
    ulRate                : uLong;             // Rate / Scale == frames/second
    ulStart               : uLong;             // delay time marking beginning or start of stream
    ulLength              : uLong;
    ulTotalFrames         : uLong;             // total number of video frames
    ulInitialFrames       : uLong;
    mmtimePerFrame        : mmTime;            // frame display time or 0L
    ulSuggestedBufferSize : uLong;
    genpalVideo           : GenPal;            // palette
    pmmXDIBHeader         : pmmXDIBHeader;     // windows DIB compatible header
  end;
  pmmVideoHeader = ^mmVideoHeader;

const
  // ulContentType Defines:
  MMIO_VIDEO_UNKNOWN            = $00000000;   // Unknown video content
  MMIO_VIDEO_DATA               = $00000001;   // Video

{----[ SW ]----}

// Secondary Windows and Graphic Buttons

const
  MAX_SMBDTEXT                  = 35;

  MB_ICONCUSTOM                 = $0001;

  SC_DEFAULTSIZE                = $c000;       // WM_COMMAND from SysMenu

  WM_INITSECONDARYWINDOW        = $0519;       // MP1: NULL, MP2: CreateParams

  QS_FRAME                      = $1;          // Flag set to query frame
  QS_DIALOG                     = $2;          // Flag set to query dialog

type
  smbd = record
    achText   : Array[0..MAX_SMBDTEXT] of char; // Text of the button. eg. "~Cancel"
    idButton  : uLong;                         // Button ID returned when user chooses button
    flStyle   : Long;                          // Button style or'ed with internal styles
  end;
  psmbd = ^smbd;

  smbInfo = record
    hIcon             : hPointer;              // Icon handle
    cButtons          : uLong;                 // Number of buttons
    flStyle           : uLong;                 // Icon style flags (MB_ICONQUESTION, etc...)
    hwndNotify        : hwnd;                  // Reserved
    psmbd             : psmbd;                 // Array of button definitions
  end;
  psmbInfo = ^smbInfo;

// Analogous to WinDlgBox
function WinSecondaryWindow( hwndParent: hwnd; hwndOwner: hwnd;
  pfnDlgProc: fnWp; hmod: hModule; idDlg: uLong; pCreateParams: Pointer): uLong;

// Analogous to WinLoadDlg
function WinLoadSecondaryWindow( hwndParent: hwnd; hwndOwner: hwnd;
  pfnDlgProc: fnWp; hmod: hModule; idDlg: uLong; pCreateParams: Pointer): hwnd;

// Analogous to WinProcessDlg
function WinProcessSecondaryWindow( hwndSW: hwnd ): uLong;

// Analogous to WinCreateDlg
function WinCreateSecondaryWindow( hwndParent: hwnd; hwndOwner: hwnd;
  pfnDlgProc: fnWp; idDlg: uLong; pCreateParams: Pointer): hwnd;

function WinDefaultSize( Wnd: hwnd): Bool;

function WinInsertDefaultSize(Wnd: hwnd; pszDefaultSize: pChar): bool;

function WinQuerySecondaryhwnd(Wnd: hwnd; ulFlag: uLong): hwnd;

//**********************************************************************
// WinSecondaryMessageBox
//
// Parameters: hwnd   hwndParent   - handle of the parent window.
//             hwnd   hwndOwner    - handle of the owner window.
//             PSZ    pszText      - message text.
//             PSZ    pszCaption   - title of the message box.
//             uLong  idWindow     - Message box id
//             PSMBINFO psmbinfo   - pointer to button/icon info
//**********************************************************************
function WinSecondaryMessageBox( hwndParent: hwnd; hwndOwner: hwnd;
  pszText: pChar; pszCaption: pChar; idWindow: uLong; smb: psmbinfo): uLong;

//**********************************************************************
// WinDismissSecondaryWindow
//
// This function should be called from within the dlg proc. The hwnd
// passed in MUST be the handle to the actual dialog.
//**********************************************************************
function WinDismissSecondaryWindow(hwndDlg: hwnd; ulResult: uLong): Bool;

//**********************************************************************
// The parameter hwnd can be either the secondary window or the actual
// dialog.
//**********************************************************************
function WinDestroySecondaryWindow(Wnd: hwnd): Bool;

function WinDefSecondaryWindowProc(Wnd: hwnd; msg: uLong;
  mp1: mParam; mp2: mParam): mResult;


//**********************************************************************
//                         Graphic Buttons
//**********************************************************************

//**********************************************************************
// Notes on Using GraphicButtons
//
// GraphicButton CONTROL DATA
//
//  The format of the control data for GraphicButtons is
//         "button Text, number of bitmaps, bitmap resource id's ..."
//
//
//  Following are two example window templates of GraphicButtons:
//
//      1)  CONTROL  "", IDD_MP_REV, 120, 10, TS_PB_WIDTH, TS_PB_HEIGHT,
//                 WC_GRAPHICBUTTON,
//                 GBS_TWOSTATE | GBS_HILITEBITMAP |
//                 WS_VISIBLE | WS_TABSTOP
//                 CTLDATA GB_RESOURCE,"~REV", 2, ID_MP_REV1, ID_MP_REV0
//
//  The above graphicbutton has id IDD_MP_REV and is of type
//  GBS_TWOSTATE and GBS_HILITEBITMAP.  The GBS_HILITEBITMAP allows
//  a different bitmap to be displayed when the button is in the
//  hilite state. The graphicbutton will be displayed with text
//  "REV" and has "R" as the mnemonic.  It has 2 bitmaps associated
//  with it.  Their resource id are ID_MP_REV1 and ID_MP_REV0.
//
//
//      2)   CONTROL  "", IDD_MP_PLAY, 175, 10, TS_PB_WIDTH,
//                        TS_PB_HEIGHT, WC_GRAPHICBUTTON,
//                        GBS_AUTOTWOSTATE | GBS_AUTOANIMATION |
//                        WS_VISIBLE | WS_TABSTOP
//                        CTLDATA GB_RESOURCE, "~PLAY", 9,
//                                ID_MP_STOP0, ID_MP_PLAY1, ID_MP_PLAY2,
//                                ID_MP_PLAY3, ID_MP_PLAY4, ID_MP_PLAY5,
//                                ID_MP_PLAY6, ID_MP_PLAY7, ID_MP_REV1
//
//  The above graphicbutton has id IDD_MP_PLAY and is of type
//  GBS_AUTOTWOSTATE and GBS_AUTOANIMATE.  When clicked upon,
//  the button will automatically toggle the state and animation.
//  The graphicbutton will be displayed with text "PLAY"
//  and mnemonic "P".  It has 9 bitmaps associated with it.
//
//
//
//  GraphicButton Painting
//
//  Due to the PM design, whenever a graphicbutton is clicked,
//  it is sent a BN_PAINT (to paint a non-hilite state) and then
//  BN_CLICKED.  Thus, for GBS_AUTO* style graphicbuttons, a paint
//  request is generated before the button has a chance to change
//  its state (BN_CLICKED).  To avoid this premature painting,
//  code was inserted to delay the painting of graphicbuttons
//  GB_PAINT_RESOLUTION milliseconds whenever the button is switching
//  FROM the hilite paint state.
//
//**********************************************************************

function WinRegisterGraphicButton: Boolean;

const
  WC_GRAPHICBUTTON              = pChar( $ffff0040 );

  //             GraphicButton Animation/TwoState constants

  //                     Graphic Button Style bits
  GBS_TWOSTATE                  = $1000;       // indicates TwoState button
  GBS_AUTOTWOSTATE              = $2000;       // will auto toggle state up/down
  GBS_ANIMATION                 = $4000;       // indicates Animatable button
  GBS_AUTOANIMATION             = $8000;       // will auto toggle anim. on/off
  GBS_DISABLEBITMAP             = $0010;       // allows a diff. bitmap when disabled
  GBS_HILITEBITMAP              = $0020;       // allows a diff. bitmap when hilited
  GBS_3D_TEXTRECESSED           = $0040;       // display text in 3-D recessed
  GBS_3D_TEXTRAISED             = $0080;       // display text in 3-D raised
  GBS_MINIBUTTON                = $0001;       // mini button style

  //                     Graphic Button User Constants

  // Codes to reference allowed GraphicButton states (or paint states)
  GB_ERROR                      = -1;          // GraphicButton Error
  GB_UP                         = 1;           // GraphicButton up (and paint) state
  GB_DOWN                       = 2;           // GraphicButton down (and paint) state
  GB_DISABLE                    = 3;           // GraphicButton disabled state
  GB_HILITE                     = 4;           // GraphicButton paint state only
  GB_OUTOFHILITE                = 5;           // Changing out of hilite paint state

  // Codes for various GraphicButton message function parameters
  GB_TOGGLE                     = 10;          // GraphicButton toggle
  GB_CURRENTSTATE               = 11;          // GraphicButton's current state
  GB_ANIMATIONBEGIN             = 12;          // when refering to index of anim start
  GB_ANIMATIONEND               = 13;          // when refering to index of anim end
  GB_MAXINDEX                   = 14;          // GraphicButton max. index

  // Codes to set/query text position relative to the bitmap
  GB_TEXTBELOW                  = 1;           // place text below bitmap
  GB_TEXTABOVE                  = 2;           // place text above bitmap

  // Codes used to set the animation frame with message GBM_SETBITMAPINDEX

  GB_INDEX_FORWARD              = -1;          // advance one frame foward
  GB_INDEX_BACKWARD             = -2;          // advance one frame backwards
  GB_INDEX_FIRST                = -3;          // set to first frame of sequence
  GB_INDEX_LAST                 = -4;          // set to last frame of sequence

type
  gbtnCdata = record
    usReserved   : uShort;
    pszText      : pChar;
    hmod         : hModule;
    cBitmaps     : uShort;
    aidBitmap    : Array[0..1] of uShort;
  end;
  pgbtnCdata = ^gbtnCdata;

const
  GB_RESOURCE                   = 1;
  GB_STRUCTURE                  = 0;


  //**********************************************************************
  //          Notification Messages received by GraphicButton Parent
  //*********************************************************************
  //**********************************************************************
  // GBN_BUTTONDOWN, GBN_BUTTONUP, and GBN_BUTTONHILITE
  //
  // The notification messages are passed as part of the WM_CONTROL
  // message.
  //
  // msg = WM_CONTROL
  // mp1 = MPFROM2SHORT(gpb_id, button_state)
  //         gpd_id       = identity of the displayed graphic pushbutton
  //         button_state = GBN_BUTTONUP, GBN_BUTTONDOWN, or
  //                        GBN_BUTTONHILITE
  //
  //**********************************************************************

  GBN_BUTTONUP                  = $0524;
  GBN_BUTTONDOWN                = $0525;
  GBN_BUTTONHILITE              = $0526;
  GBN_SETFOCUS                  = $0527;   // mp2 TRUE for gaining focus

  //**********************************************************************
  //          Messages to GraphicButton Windows
  //**********************************************************************

  //**********************************************************************
  //                             GBM_SETGRAPHICDATA
  //**********************************************************************
  // mp1 = MPFROMP((PGBTNCDATA)&gbtncdata);    Graphic button control data
  // mp2 = NULL;                               not used
  //
  // WARNING: This message resets all button parameters.
  //
  //**********************************************************************

  GBM_SETGRAPHICDATA            = $052A;

  //**********************************************************************
  //                             GBM_ANIMATE
  //**********************************************************************
  // mp1 = MPFROMSHORT(fStart)      TRUE to start animation, FALSE to stop
  // mp2 = MPFROMSHORT(fContinue)   TRUE continue anim. at currently
  //                                displayed bitmap, FALSE restart at
  //                                the beginning.
  //
  // Returns TRUE on Success
  //         FALSE on Failure
  //
  //**********************************************************************

  GBM_ANIMATE                   = $052B;

  //**********************************************************************
  //                             GBM_SETANIMATIONRATE
  //**********************************************************************
  // mp1 = MPFROMSHORT(ULmIL);      Animation rate in milliseconds
  // mp2 = NULL                     not used
  //
  //
  // Returns TRUE on Success
  //         FALSE on Failure
  //
  //**********************************************************************

  GBM_SETANIMATIONRATE          = $052C;


  //**********************************************************************
  //                             GBM_QUERYANIMATIONACTIVE
  //**********************************************************************
  // mp1 = NULL;                    not used
  // mp2 = NULL;                    not used
  //
  //
  // Returns TRUE if animation is active, else GB_ERROR
  //
  //
  //**********************************************************************

  GBM_QUERYANIMATIONACTIVE      = $052D;


  //**********************************************************************
  //                             GBM_QUERYANIMATIONRATE
  //**********************************************************************
  // mp1 = NULL;                    not used
  // mp2 = NULL;                    not used
  //
  //
  // Returns uLong sepcifying animation rate in milliseconds
  //
  //
  //**********************************************************************

  GBM_QUERYANIMATIONRATE        = $052E;


  //**********************************************************************
  //                             GBM_SETBITMAPINDEX
  //**********************************************************************
  // mp1 = MPFROMSHORT(usGB_State)       Bitmap index to change
  //             GB_UP,
  //             GB_DOWN,
  //             GB_DISABLE,
  //             GB_HILITE,
  //             GB_ANIMATIONBEGIN,
  //             GB_ANIMATIONEND,
  //          or GB_CURRENTSTATE    chng current state (up or down) bitmap
  // mp2 = MPFROMSHORT(sFrameCode)  Set according to code or frame desire
  //             GB_INDEX_FORWARD,  chng to next bitmap in circular array
  //             GB_INDEX_BACKWARD, "   "  prev   "    "     "       "
  //             GB_INDEX_FIRST,    "   "  first  "    "     "       "
  //             GB_INDEX_LAST,     "   "  last   "    "     "       "
  //          or desired_bitmap     otherwise desired bmp index specified
  //
  // Returns TRUE on Success, otherwise FALSE
  //
  //**********************************************************************

  GBM_SETBITMAPINDEX            = $052F;


  //**********************************************************************
  //                             GBM_QUERYBITMAPINDEX
  //**********************************************************************
  //  mp1 = MPFROMSHORT(usGB_State)       Query bitmap index
  //            GB_UP,
  //            GB_DOWN,
  //            GB_DISABLE,
  //            GB_HILITE,
  //            GB_ANIMATIONBEGIN,
  //            GB_ANIMATIONEND,
  //         or GB_CURRENTSTATE  query current state (up or down) bitmap
  //  mp2 = NULL;                    not used
  //
  //  Returns USHORT specifying the index
  //
  //
  //**********************************************************************

  GBM_QUERYBITMAPINDEX          = $0530;

  //**********************************************************************
  //                             GBM_SETSTATE
  //**********************************************************************
  // mp1 = MPFROMSHORT(usStateCode)   Set twostate button to specified
  //                                  state
  //             GB_UP,
  //             GB_DOWN,
  //          or GB_TOGGLE          toggle (up/down) to (down/up)
  // mp2 = MPFROMBOOL(fRepaint)     TRUE  - state changed and displayed
  //                                FALSE - state changed, not displayed
  //
  // Returns TRUE on Success
  //         FALSE on Failure
  //
  //
  //**********************************************************************

  GBM_SETSTATE                  = $0531;

  //**********************************************************************
  //                             GBM_QUERYSTATE
  //**********************************************************************
  //
  // mp1 = NULL                        not used
  // mp2 = NULL                        not used
  //
  // Returns the state (GB_UP or GB_DOWN) else GB_ERROR.
  //
  //
  //**********************************************************************

  GBM_QUERYSTATE                = $0532;

  //**********************************************************************
  //                             GBM_SETTEXTPOSITION
  //**********************************************************************
  // mp1 = MPFROMSHORT(usTextPos)   How to position text relative to
  //                                  bitmap
  //               GB_TEXTBELOW,
  //            or GB_TEXTABOVE
  //   mp2 = NULL                     not used
  //
  //   Returns TRUE on Success, otherwise FALSE
  //
  //**********************************************************************

  GBM_SETTEXTPOSITION           = $0533;

  //**********************************************************************
  //                             GBM_QUERYTEXTPOSITION
  //**********************************************************************
  //
  //  mp1 = NULL                          not used
  //  mp2 = NULL                          not used
  //
  //  Returns GB_TEXTBELOW, GB_TEXTABOVE, GB_TEXTRIGHT, GB_TEXTLEFT
  //  on success, otherwise FALSE
  //
  //**********************************************************************

  GBM_QUERYTEXTPOSITION         = $0534;


  //**********************************************************************
  //                             GraphicButton END
  //**********************************************************************

  MM_TABHELP                    = $054C;

{----[ DIVE ]----}

const
  Max_Dive_Instances = 64;

type
  hDive  = ULong;

const
  Dive_Success                     = $00000000;
  Dive_Err_Invalid_Instance        = $00001000;
  Dive_Err_Source_Format           = $00001001;
  Dive_Err_Destination_Format      = $00001002;
  Dive_Err_Blitter_Not_Ssetup      = $00001003;
  Dive_Err_Insufficient_Length     = $00001004;
  Dive_Err_Too_Many_Instances      = $00001005;
  Dive_Err_No_Direct_Access        = $00001006;
  Dive_Err_Not_Bank_Switched       = $00001007;
  Dive_Err_Invalid_Bank_Number     = $00001008;
  Dive_Err_FB_Not_Acquired         = $00001009;
  Dive_Err_FB_Already_Acquired     = $0000100a;
  Dive_Err_Acquire_Failed          = $0000100b;
  Dive_Err_Bank_Switch_Failed      = $0000100c;
  Dive_Err_DeAcquire_Failed        = $0000100d;
  Dive_Err_Invalid_Palette         = $0000100e;
  Dive_Err_Invalid_Destination_Rectl=$0000100f;
  Dive_Err_Invalid_Buffer_Number   = $00001010;
  Dive_Err_SSMDD_Not_Installed     = $00001011;
  Dive_Err_Buffer_Already_Accessed = $00001012;
  Dive_Err_Buffer_Not_Accessed     = $00001013;
  Dive_Err_Too_Many_BufferS        = $00001014;
  Dive_Err_Allocation_Error        = $00001015;
  Dive_Warn_No_Size                = $00001100;

  Dive_Buffer_Screen               = $00000000;
  Dive_Buffer_Graphics_Plane       = $00000001;
  Dive_Buffer_Alternate_Plane      = $00000002;

{ Notes:
      Associated/Allocated memory buffers start at:      $00000010

      Specifing Dive_Buffer_GRAPHICS_PLANE results in the image being
            transferred to the graphics plane.
      Specifing Dive_Buffer_ALTERNATE_PLANE results in the image being
            transferred to the alternate (e.g. overlay) plane.  If your
            hardware doesn't support such a plane, this is an error.
      Specifing Dive_Buffer_Screen will result in the image being
            transferred to either the graphics plane buffer or the alternate
            plane buffer based on if an alternate buffer exists and based on
            the suitability the overlay plane to accelerate the scaling of
            the image.  If Dive chooses to use the alternate buffer, it
            will also paint the overlay "key" color on the graphics plane.
            This automatic painting does not occur if the alternate plane
            is explicitly specified.
}

type
  Dive_Caps = record
    ulStructLen           : ULong;   // Set equal to sizeof(Dive_CAPS)
    ulPlaneCount          : ULong;   // Number of defined planes.

    // Info returned in the following fields pertains to ulPlaneID.
    fScreenDirect         : Bool;    // TRUE if can get addressability to vram.
    fBankSwitched         : Bool;    // TRUE if vram is bank-switched.
    ulDepth               : ULong;   // Number of bits per pixel.
    ulHorizontalResolution: ULong;   // Screen width in pixels.
    ulVerticalResolution  : ULong;   // Screen height in pixels.
    ulScanLineBytes       : ULong;   // Screen scan line size in bytes.
    fccColorEncoding      : FourCC;  // Colorspace encoding of the screen.
    ulApertureSize        : ULong;   // Size of vram aperture in bytes.

    ulInputFormats        : ULong;   // Number of input color formats.
    ulOutputFormats       : ULong;   // Number of output color formats.
    ulFormatLength        : ULong;   // Length of format buffer.
    pFormatData           : Pointer; // Pointer to color format buffer FourCC's.
  end;

  pDive_Caps=^Dive_Caps;


{ Notes:
      DiveSetupBlitter may be called with a structure length at any of the
      breaks below (i.e. 8, 28, 32, 52, 60, or 68):
}

  Setup_Blitter = record
    ulStructLen           : ULong;   // Set equal to sizeof(SETUP_Blitter)
    fInvert               : Bool;    // TRUE if we are to invert image on blit.

    fccSrcColorFormat     : FourCC;  // Color format of Source data.
    ulSrcWidth            : ULong;   // Source width in pixels.
    ulSrcHeight           : ULong;   // Source height in pixels.
    ulSrcPosX             : ULong;   // Source start X position.
    ulSrcPosY             : ULong;   // Source start Y position.

    ulDitherType          : ULong;   // Where 0 is no dither, 1 is 2x2 dither.

    fccDstColorFormat     : FourCC;  // Color format of destination data.
    ulDstWidth            : ULong;   // Destination width in pixels.
    ulDstHeight           : ULong;   // Destination height in pixels.
    lDstPosX              : Long;    // Destination start X position.
    lDstPosY              : Long;    // Destination start Y position.

    lScreenPosX           : Long;    // Destination start X position on screen.
    lScreenPosY           : Long;    // Destination start Y position on screen.

    ulNumDstRects         : ULong;   // Number of visible rectangles.
    pVisDstRects          : PRectl;  // Pointer to array of visible rectangles.
  end;

  pSetup_Blitter = ^Setup_Blitter;

Function DiveQueryCaps( var DiveCaps: Dive_Caps; ulPlaneBufNum: ULong): ULong;
Function DiveOpen( var hDiveInst: hDive; fNonScreenInstance: Bool;
                   var pFrameBuffer: Pointer): ULong;
Function DiveSetupBlitter( hDiveInst: hDive; pSetupBlitter: pSetup_Blitter): ULong;
Function DiveBlitImage( hDiveInst: hDive; ulSrcBufNumber: ULong;
                        ulDstBufNumber: ULong): ULong;
Function DiveClose( hDiveInst: hDive ): ULong;
Function DiveAcquireFrameBuffer( hDiveInst: ULong; var rectlDst: RectL ): ULong;
Function DiveSwitchBank( hDiveInst: hDive; ulBankNumber: ULong): ULong;
Function DiveDeacquireFrameBuffer( hDiveInst: hDive ): ULong;
Function DiveCalcFrameBufferAddress( hDiveInst: hDive;
                                     var rectlDest: RECTL;
                                     var pDestinationAddress: Pointer;
                                     var ulBankNumber: ULong;
                                     var ulRemLinesInBank: ULong): ULong;

{ Notes on DiveAllocImageBuffer:
      If ImageBuffer is not NULL, the buffer is associated rather than
      allocated.  If ImageBuffer is not NULL and the buffer number
      pointed to by pulBufferNumber is non-zero, a new buffer pointer is
      associated with the buffer number.  Even though no memory is
      allocated by DiveAllocImageBuffer when user-allocated buffers are
      associated, DiveFreeImageBuffer should be called to release the
      buffer association to avoid using up available buffer indexes.
      The specified line size will be used if a buffer is allocated in
      system memory, or if a user buffer is associated.  If the
      specified line size is zero, the allocated line size is rounded up
      to the nearest DWORD boundary. }

Function DiveAllocImageBuffer( hDiveInst: hDive; var ulBufferNumber: ULong;
                               fccColorSpace: FourCC; ulWidth: ULong;
                               ulHeight: ULong; ulLineSizeBytes: ULong;
                               ImageBuffer: Pointer): ULong;
Function DiveFreeImageBuffer( hDiveInst: hDive; ulBufferNumber: ULong):ULong;
Function DiveBeginImageBufferAccess( hDiveInst: hDive; ulBufferNumber: ULong;
                                     var pbImageBuffer: Pointer;
                                     var ulBufferScanLineBytes: ULong;
                                     var ulBufferScanLines: ULong): ULong;

Function DiveEndImageBufferAccess( hDiveInst: hDive; ulBufferNumber: ULong): ULong;

{ Notes on palettes:
      Neither DiveSetSourcePalette nor DiveSetDestinationPalette API's will set
      the physical palette.  If your application MUST set the PHYSICAL palette,
      try using no more than 236 entries (the middle 236: 10-245, thus leaving
      the top and bottom 10 entries for the Workplace Shell).  If your
      application MUST use ALL 256 entries, it must do so as a full-screen
      (i.e. maximized) application.  Remember, No WM_REALIZEPALETTE message
      will be sent to other running applications, meaning they will not redraw
      and their colors will be all wrong.  It is not recommended that a
      developer use these commands:

   To set physical palette, do the following:
            hps := WinGetPS( HWND_DESKTOP );
            hdc := GpiQueryDevice( hps );
            GpiCreateLogColorTable( hps, LCOL_PURECOLOR OR LCOL_REALIZABLE,
                           LCOLF_CONSECRGB, 0, 256, @plRGB2Entries );
            DiveSetPhysicalPalette( hDiveInst, hdc );
            Gre32EntrY3 ( hdc, 0, $000060C6L );
            WinInvalidateRect ( HWND_DESKTOP, nil, ord(TRUE) );
            WinReleasePS ( hps );

   To reset physical palette, do the following:
            hps := WinGetPS ( HWND_DESKTOP );
            hdc := GpiQueryDevice ( hps );
            Gre32EntrY3 ( hdc, 0, $000060C7L );
            WinInvalidateRect ( HWND_DESKTOP, nil, ord(TRUE) );
            WinReleasePS ( hps ); }

Function DiveSetDestinationPalette( hDiveInst: hDive; ulStartIndex: ULong;
                                    ulNumEntries: ULong; pbRGB2Entries: Pointer): ULong;

Function DiveSetSourcePalette( hDiveInst: hDive; ulStartIndex: ULong;
                               ulNumEntries: ULong; pbRGB2Entries: Pointer): ULong;

{----[ MIDIOS2 ]----}

// Multimedia Extensions Midi structures and definitions

const
  STATUS_BIT                    = $80;

  TRACK_OFF                     = 0;
  TRACK_ON                      = 1;


  NORMAL_SYSEX                  = $f0;
  ESCAPE_SYSEX                  = $f7;
  META                          = $ff;

  // user defined messages for IO PROC
  MMIO_SEQ                      = MMIOM_USER + 1;
  MMIO_MERGE                    = MMIOM_USER + 2;
  MMIO_FROM_SEQ                 = MMIOM_USER + 3;
  MMIO_TIMED_READ               = MMIOM_USER + 4;
  MMIO_SET_TRACKS               = MMIOM_USER + 5;
  MMIO_FORMAT_0                 = MMIOM_USER + 6;
  MMIO_GETHEADER                = MMIOM_GETHEADER;
  MMIOM_GETFILELENGTH           = MMIOM_USER + 10;
  MMIOM_GETTRACKLENGTH          = MMIOM_USER + 11;

type
  MidiHeader = record
    chHeaderChunk               : array[0..3] of Char;
    ulHeaderLength              : uLong;
    usFormat                    : uShort;
    usNumTracks                 : uShort;
    usDivision                  : uShort;
    vpAdditionalInformation     : Pointer;
  end;
  pMidiHeader = ^MidiHeader;

  mmMidiHeader = record
    ulHeaderLength    : uLong;                 // Length in Bytes
    ulContentType     : uLong;                 // Image content
    ulMediaType       : uLong;                 // type of media
    midiheader        : MidiHeader;            // header
  end;
  pmmMidiHeader = ^mmMidiHeader;

{----[ MIDITYPE2 ]----}

const
  MIDINAMESIZE                  = 40;
  MIDIPATCHNUM                  = 128;
  MIDITYPEAPPNAME               = 'MidiTypes';    // Appname in MIDITYPE.INI

type
  // These structures describe the format of the MIDI maps that are
  // located in the MIDITYPE.INI file.
  MidiTypeEntry = record
    uGenMidiPatchNumber  : uShort;             // Device To General Midi Conversion
    uDevMidiPatchNumber  : uShort;             // General Midi to Device Conversion
    uVolumePercent       : uShort;             // Channel Patch Volume Scaler
    uGenMidiKeyNumber    : uShort;             // Device To General Midi Perc. Key Conversion
    uDevMidiKeyNumber    : uShort;             // General Midi to Device Perc. Key Conversion
  end;
  pMidiTypeEntry = ^MidiTypeEntry;

  MidiType = record
    uStyle            : uShort;                // Midi Style
    uDrums10          : uShort;                // Patch 10 Drums if Perckey not supported
    uDrums16          : uShort;                // Patch 16 Drums if Perckey not supported
    ulReserved        : uLong;                 // Reserved
    MidiTypeEntry     : array[0..midiPatchNum-1] of MIDITYPEENTRY;
                                               // Array of MIDITYPEENTRYs
    szPatchAndPercKeyName: array[0..2*MIDIPATCHNUM*MIDINAMESIZE-1] of char;
                                               // List of 128 Patch Names
                                               // that are null terminated, then a
                                               // list of 128 Percussion key names that
                                               // are double null terminated
                                               // Each item is null terminated
  end;
  pMidiType = ^MidiType;

const
  // Style Flags
  MT_PERCUSSIONKEYS             = $1;          // Percussion Keys are supported
  MT_MAPPERCKEYPATCHES          = $2;          // Map Percussion Key Patches

{----[ AUDIO ]----}

// Multimedia Extensions Audio Structures and definitions.

const
  // * AUDIODD version level
  CURRENT_VERSION               = $01020000;

  // ACPA control definitions
  AUDIO_IOCTL_CAT               = $80;

  AUDIO_INIT                    = $40;
  AUDIO_STATUS                  = $41;
  AUDIO_CONTROL                 = $42;
  AUDIO_BUFFER                  = $43;
  AUDIO_LOAD                    = $44;
  AUDIO_WAIT                    = $45;
  AUDIO_HPI                     = $46;
  AUDIO_CAPABILITY              = $48;

  MIX_GETCONNECTIONS            = $60;
  MIX_SETCONNECTIONS            = $61;
  MIX_GETLINEINFO               = $62;
  MIX_GETCONTROL                = $63;
  MIX_SETCONTROL                = $64;

  // AUDIO_INIT declarations and defines
  LOAD_PATH                     = 260;

  // Values for AUDIO_INIT.sMode
  ADPCM                         = 1;           // AVC type ADPCM
  PCM                           = 2;           // Pulse Coded Modulation
  MU_LAW                        = 3;           // mu-law
  MIDI                          = 4;           // MIDI data
  A_LAW                         = 5;           // a-law
  SOURCE_MIX                    = 6;           // External audio source
  SPV2                          = 7;           // Speech Viewer/2
  ADPCMXA                       = 8;           // XA CD ROM
  SPV2BCPCM                     = 25;          // Speech Viewer/2
  SPV2PCM                       = 26;
  SPV2NONE                      = 27;
  IDLE                          = 999;
  CLAIM_HDWR                    = 32000;       // Serialize access to hardware

  // Values for AUDIO_INIT.ulFlags
  FIXED                         = $00000001;   // Fixed length data
  LEFT_ALIGNED                  = $00000002;   // Left align bits on byte bndry
  RIGHT_ALIGNED                 = $00000004;   // Right align bits on byte bndry
  TWOS_COMPLEMENT               = $00000008;   // 2's complement data
  SIGNED                        = $00000010;   // Signed data
  BIG_ENDIAN                    = $00000020;   // MSB's first (motorola format)
  RIFF_DATATYPE                 = $00000040;   // sMode contains a RIFF datatype
  PITCH                         = $00100000;   // Pitch control is supported
  INPUT                         = $00200000;   // Input select is supported
  OUTPUT                        = $00400000;   // Output select is supported
  MONITOR                       = $00800000;   // Monitor is supported
  VOLUME                        = $01000000;   // Volume control is supported
  VOLUME_DELAY                  = $02000000;   // Volume delay is supported
  BALANCE                       = $04000000;   // Balance control is supported
  BALANCE_DELAY                 = $08000000;   // Balance delay is supported
  TREBLE                        = $10000000;   // Treble control is supported
  BASS                          = $20000000;   // Bass control supported
  BESTFIT_PROVIDED              = $40000000;   // bestfit returned
  LOAD_CODE                     = $80000000;   // DSP load needed

  // Values for AUDIO_INIT.ulOperation
  OPERATION_PLAY                = 1;
  OPERATION_RECORD              = 2;
  PLAY_AND_RECORD               = 3;
  ANALYSIS                      = 6;           // Speech Viewer/2
  DISTANCE                      = 7;           // Speech Viewer/2
  MIGRATION                     = 8;           // Speech Viewer/2

  // Values for AUDIO_INIT.sReturnCode
  NO_PLAY                       = 1;
  NO_RECORD                     = 2;
  NO_RECORD_AND_PLAY            = 3;
  INVALID_REQUEST               = 4;
  CONFLICT                      = 5;
  OVERLOADED                    = 6;
  DOWNLEVEL_DD                  = 7;           // DD is down level from appl.
  DSP_LOAD_PENDING_ON_OTHER_TRK = 8;           // Other trk hasn't loaded dsp

  AUDIO_IGNORE                  = -1;

  // Values for AUDIO_INIT.sDeviceID
  MINIDD                        = 0;
  ACPA                          = 1;
  MACPA                         = 2;
  MPU401                        = 3;
  SOUND_BLASTER                 = 4;
  IMF                           = 5;
  PS1                           = 6;
  PAS16                         = 7;

type
  // AUDIO_INIT structure declaration
  mci_Audio_Init = record
    lSRate            : Long;
    lBitsPerSRate     : Long;
    lBsize            : Long;
    sMode             : Short;
    sChannels         : Short;
    lResolution       : Long;
    abLoadPath        : array[0..Load_Path-1] of Char;
    ulFlags           : uLong;
    ulOperation       : uLong;
    sReturnCode       : Short;
    sSlotNumber       : Short;
    sDeviceID         : Short;
    pvReserved        : Pointer; // MMPM2 uses this to pass back sysfilenum
    ulVersionLevel    : uLong;
  end;
  lpmci_Audio_Init = ^mci_Audio_Init;

  // AUDIO_DEVID declarations and defines
  mci_Audio_DevID = record
    ulDevType         : uLong;
    ulDevNum          : uLong;
  end;
  lpmci_Audio_DevID = ^mci_Audio_DevID;

const
  // Input devices
  NULL_INPUT                    = 0;
  STEREO_LINE_INPUT             = 1;
  LEFT_LINE_INPUT               = 2;
  RIGHT_LINE_INPUT              = 3;
  MIC_INPUT                     = 4;
  BOOSTED_MIC_INPUT             = 5;
  PHONE_LINE_INPUT              = 6;
  HANDSET_INPUT                 = 7;
  SYNTH_INPUT                   = 8;
  DIGITAL_PHONE_LINE_INPUT      = 9;
  DIGITAL_HANDSET_INPUT         = 10;
  MIDI_IN_PORT                  = 11;
  LOOPBACK                      = 11;
  DEFAULT_INPUT                 = $FFFFFFFF;

  // Output devices
  NULL_OUTPUT                   = 0;
  STEREO_LINE_OUTPUT            = 1;
  LEFT_LINE_OUTPUT              = 2;
  RIGHT_LINE_OUTPUT             = 3;
  SPEAKER_OUTPUT                = 4;
  HEADSET_OUTPUT                = 5;
  PHONE_LINE_OUTPUT             = 6;
  HANDSET_OUTPUT                = 7;
  SYNTH_OUTPUT                  = 8;
  DIGITAL_PHONE_LINE_OUTPUT     = 9;
  DIGITAL_HANDSET_OUTPUT        = 10;
  MIDI_OUT_PORT                 = 11;
  DEFAULT_OUTPUT                = $FFFFFFFF;

  // Defined values for DevNum
  DEFAULT_DEVICE                = 0;
  DEVICE_1                      = 1;
  DEVICE_2                      = 2;

  // Valid Return codes for the ulSupport field of MCI_AUDIO_CAPS
  SUPPORT_SUCCESS               = $00000000;
  UNSUPPORTED_RATE              = $00000001;
  UNSUPPORTED_CHANNELS          = $00000002;
  UNSUPPORTED_BPS               = $00000004;
  UNSUPPORTED_DATATYPE          = $00000008;
  UNSUPPORTED_OPERATION         = $00000010;

type
  mci_Audio_Caps = record
    ulLength          : uLong;                 // in     Structure length
    ulSamplingRate    : uLong;                 // in out Sampling rate to query
    ulChannels        : uLong;                 // in out Channels to query
    ulBitsPerSample   : uLong;                 // in out BPS to query
    ulDataType        : uLong;                 // in out RIFF Datatype to query
    ulOperation       : uLong;                 // in out OPERATION_PLAY or OPERATION_RECORD
    ulSupport         : uLong;                 //    out BOOLEAN-does DD support this mode
    ulDataSubType     : uLong;                 //    out Data-subtype to use
    ulResourceUnits   : uLong;                 //    out Resource units this mode
    ulResourceClass   : uLong;                 //    out Resource class for this mode
    ulBlockAlign      : uLong;                 //    out Block alignment for this mode.
    fCanRecord        : uLong;                 //    out Is recording possbile - this mode
    ulFlags           : uLong;                 //    out
    ulCapability      : uLong;                 //    out Capability of the device.
  end;
  pAudio_Caps = ^mci_Audio_Caps;

const
  // Valid Return codes for the ul field of MCI_AUDIO_CAPS
  SUPPORT_MIX                   = $00000001; // supports mixer functions
  SUPPORT_RIFF_MODES            = $00000002; // supports RIFF modes for AUDIO_INIT
  SUPPORT_CAP                   = $80000000; // Capability IOCTL supported

  // AUDIO_CHANGE declarations and defines

  // Values for AUDIO_CHANGE.lMonitor
  MONITOR_OFF                   = 0;
  MONITOR_UNCOMPRESSED          = 1;
  MONITOR_COMPRESSED            = 2;

  // Values for AUDIO_CHANGE.lInput
  HIGH_GAIN_MIC                 = 0;
  LINE_1                        = 1;
  LINE_2                        = 2;
  LINES_1AND2                   = 3;
  LOW_GAIN_MIC                  = 4;
  ALL_LINES                     = $FFFF;
  INPUTS_LISTED                 = $5555;

  // Values for AUDIO_CHANGE.lOutput
  EXTERNAL_SPEAKER              = 1;
  INTERNAL_SPEAKER              = 2;
  OUTPUT_1                      = 4;
  OUTPUTS_LISTED                = $5555;

type
  // AUDIO_CHANGE structure declaration
  mci_Audio_Change = record
    pvDevInfo         : Pointer;
    lInput            : Long;
    lOutput           : Long;
    lMonitor          : Long;
    lVolume           : Long;
    lVolumeDelay      : Long;
    lBalance          : Long;
    lBalanceDelay     : Long;
    lTreble           : Long;
    lBass             : Long;
    lPitch            : Long;
    rInputList        : array[0..7] of MCI_AUDIO_DEVID;
    rOutputList       : array[0..7] of MCI_AUDIO_DEVID;

    prMoreInputs      : LPMCI_AUDIO_DEVID;
    prMoreOutputs     : LPMCI_AUDIO_DEVID;
    lGain             : Long;
    pvModeInfo        : Pointer;
  end;
  lmmci_Audio_Change = ^mci_Audio_Change;

  Midi_Info = record
    sTempo            : Short;
    sCPQN             : Short;
    sMidiSwitches     : Short;
    sReserved         : Array[0..4] of Short;
  end;

const
  // MIDI Switches
  MIDI_THRU_THRU                = 0;
  MIDI_THRU_OUT                 = 1;

  // AUDIO_STATUS declarations and defines

  // Values for AUDIO_STATUS.ulOperation
  STOPPED                       = 0;
  PLAYING                       = 1;
  RECORDING                     = 2;
  PLAYING_AND_RECORDING         = 3;
  UNITIALIZED                   = $FFFFFFFF;

type
  // AUDIO_STATUS structure declaration
  mci_Audio_Status = record
    lSRate            : Long;
    lBitsPerSRate     : Long;
    lBsize            : Long;
    sMode             : Short;
    sChannels         : Short;
    ulFlags           : uLong;
    ulOperation       : uLong;
    rAudioChange      : MCI_AUDIO_CHANGE;
  end;
  lpmci_Audio_Status = ^mci_Audio_Status;

const
  // AUDIO_CONTROL declarations and defines

  // Values for AUDIO_CONTROL.usIOCtlRequest
  AUDIO_CHANGE                  = 0;
  AUDIO_START                   = 1;
  AUDIO_STOP                    = 2;
  AUDIO_PAUSE                   = 3;
  AUDIO_RESUME                  = 4;

  // Values for AUDIO_CONTROL.sReturnCode
  AC_UNINITED                   = 1;           // Device must be init'ed or loaded first
  FULL_QUEUE                    = 2;           // Maximum # requests exceeded
  AC_UNPAUSED                   = 3;           // Resume issued, but dev not paused
//  INVALID_REQUEST               = 4;           // bad audio_control.ioctl_request
  AC_UNSTARTED                  = 5;           // Device must be started first
  INVALID_INPUT_LIST            = 7;           // invalid change.input_list entry
  INVALID_OUTPUT_LIST           = 8;           // invalid change.output_list entry

type
  // AUDIO_CONTROL structure declaration
  mci_Audio_Control = record
    usIOCtlRequest    : uShort;
    pbRequestInfo     : Pointer;
    ulPosition        : uLong;
    sReturnCode       : Short;
  end;
  lpmci_Audio_Control = ^mci_Audio_Control;

const
  // AUDIO_BUFFER declarations and defines

  // Values for AUDIO_BUFFER.ulFlags
  AUDIO_UNDERRUN                = 1;
  AUDIO_OVERRUN                 = 2;

  // Values for AUDIO_BUFFER.ulPositionType
  POS_MSECS                     = 0;
  MIDI_CLOCKS                   = 1;
  SMPTE_24                      = 24;
  SMPTE_25                      = 25;
  SMPTE_30DF                    = 29;
  SMPTE_30                      = 30;

type
  mci_Audio_Buffer = record
    ulFlags           : uLong;
    ulReadBufSize     : uLong;
    ulWriteBufSize    : uLong;
    ulReadBufTime     : uLong;
    ulWriteBufTime    : uLong;
    ulReadBufMax      : uLong;
    ulWriteBufMax     : uLong;
    ulPosition        : uLong;
    ulPositionType    : uLong;
    lReadBufCap       : Long;
    lWriteBufCap      : Long;
    lRequestBufCap    : Long;
  end;
  lpmci_Audio_Buffer = ^mci_Audio_Buffer;

const
  // AUDIO_LOAD declarations and defines

  // Values for AUDIO_LOAD.ulFlags
  LOAD_START                    = $01;
  LOAD_END                      = $02;
  LOAD_32BIT                    = $10;

type
  mci_Audio_load = record
    pbBuffer          : pChar;
    ulSize            : uLong;
    ulFlags           : uLong;
  end;
  lpmci_Audio_load = ^mci_Audio_load;

  // Track info declarations and defines

  // Track Info structure declaration
  mci_Track_Info = record
     usMasterVolume        : UShort;
     usDitherPct           : UShort;   // Percent of a bit dither during record
     usMasterVolumeDelay   : UShort;
     usMasterBalance       : UShort;
     usMasterBalanceDelay  : UShort;
  end;
  lpmci_Track_Info = ^mci_Track_Info;

const
  // IOBUFFER declarations and defines

  STARTED                       = 1;
  PAUSED                        = 2;

type
  mci_Audio_IOBuffer = record
    lSize             : uLong;
    pHead             : pChar;
    pTail             : pChar;
    lCount            : Long;
    ulPosition        : uLong;
    lDelay            : Long;
    usRunFlags        : UShort;
    usSelInc          : UShort;
    pBuffer           : pChar;
  end;
  lpmci_Audio_IOBuffer = ^mci_Audio_IOBuffer;

const
  // AUDIO_HPI declarations and defines
  CBXMIT                        = 1;
  CBREC                         = 2;
  CRTIMER                       = 4;

  EP_OPEN                       = 0;
  EP_CLOSE                      = 1;
  EP_READ                       = 2;
  EP_WRITE                      = 3;
  EP_INIT                       = 4;
  EP_STATUS                     = 5;
  EP_CONTROL                    = 6;
  EP_BUFFER                     = 7;
  EP_LOAD                       = 8;
  EP_WAIT                       = 9;

type
  mci_Audio_hpi = record
    pvEntry           : procedure;             // VOID (FAR *pvEntry)();
    pvCallBack        : procedure;             // VOID (FAR *pvCallBack)();
    prXBuff           : lpmci_Audio_IOBuffer;
    prRBuff           : lpmci_Audio_IOBuffer;
    usFlags           : uShort;
  end;
  lpmci_Audio_hpi = ^mci_Audio_hpi;

  // AUDIO_UPDATE Structure
  Audio_Update = record
    iobuf_type        : Char;                  // 0 - XMITIO, 1 - RECIO to be updated
    buffer_address    : pChar;                 // address to buffer to be added to array
    buffer_length     : uLong;                 // length of buffer to be added
    rc                : uShort;                // return code
    reserved          : Pointer;               // future use
  end;
  Update = ^Audio_Update;

const
  // audio_update.iobuf_type definitions
  XMIT_IOBUF                    = 0;
  REC_IOBUF                     = 1;

  // audio_update.rc definitions
  MAX_NUM_BUFFERS_REACHED       = 9;
  UPDATE_GENERAL_FAILURE        = 10;
  INVALID_BUFFER_LENGTH         = 11;

{----[ CDAUDOS2 ]----}

// Macro definition and common record structures used between the
// CD Audio MCI Driver, its VSDs (Vendor Specific Drivers), and the
// CD look-up table, MMPMCD.INI.

// CD MCD and VSD values and inter-modual communications

const
  // Macro Definitions
  UPC_SIZE                      = 7;           // UPC code size, CD serial number
  CDMCD_CUEPOINT_MAX            = 20;          // maximum number of cuepoints
  CDROM_SPEC_START              = 6000;        // 2 seconds, greatest min start address


  // Internal messages between the MCI Driver and the VSD.
  MCIDRV_REGISTER_DISC          = MCI_INTERNAL_MESSAGES_START + 1;
  MCIDRV_REGISTER_DRIVE         = MCI_INTERNAL_MESSAGES_START + 2;
  MCIDRV_REGISTER_TRACKS        = MCI_INTERNAL_MESSAGES_START + 3;
  MCIDRV_CD_READ_Long           = MCI_INTERNAL_MESSAGES_START + 4;
  MCIDRV_CD_SET_VERIFY          = MCI_INTERNAL_MESSAGES_START + 5;
  MCIDRV_CD_STATUS_CVOL         = MCI_INTERNAL_MESSAGES_START + 6;

type
  // Internal callback routine to the VSD from the MCI Driver.
  fnCDvsd = function( a: Pointer; b: UShort; c: puLong; d: Pointer; e: UShort ): uLong;
  // (typedef ULONG (APIENTRY FNCDVSD) (PVOID, USHORT, ULONG *, PVOID, USHORT);)

  // Internal callback routine from the VSD to the MCI Driver.
  fnCMmcd = procedure( a,b,c: uLong );
  // (typedef VOID (*PFNCDMCD) (uLong, uLong, uLong);)

type
  // CDAudRegister record structures
  //** ID a disc, used to verify a disc change **
  mci_CD_ID = record                           // must stay at 8 bytes to equal size of UPC
    Mode              : Byte;                  // mode, 0=UPC, 1=ID
    usTrack1          : UShort;                // address of track one in MMTIME
    NumTracks         : Byte;                  // number of tracks
    ulLeadOut         : uLong;                 // address of lead out track
  end;

  //** CD-ROM Drive information, determines capabilities **
  mci_RegDrive_Parms = record
    usCaps            : UShort;                // capabilities
    ulPrerollType     : uLong;                 // preroll type
    ulPrerollTime     : uLong;                 // preroll time
    ulMinStartTime    : uLong;                 // minimum starting time
    ulCDMCDID         : uLong;                 // CD MCD ID for instance
    pCDMCDReturn      : fnCMMcd;               // addr of CD MCD Return function
  end;

const
  // These flags are valid for the usCaps Field
  CDVSD_CAP_CAN_RECORD          = $0001;       // Can record audio
  CDVSD_CAP_HAS_AUDIO           = $0002;       // Can play audio
  CDVSD_CAP_HAS_VIDEO           = $0004;       // Can play video
  CDVSD_CAP_CAN_EJECT           = $0010;       // Can eject disc
  CDVSD_CAP_CAN_STREAM          = $0020;       // Can stream
  CDVSD_CAP_HAS_DAC             = $0040;       // Can process internal
  CDVSD_CAP_CAN_LOCK            = $0080;       // Can disable manual eject
  CDVSD_CAP_CAN_VOLUME          = $0100;       // Can manipulate volume settings
  CDVSD_CAP_CAN_REVERSE         = $0200;       // Can play in reverse
  CDVSD_CAP_CAN_V_SPEED         = $0400;       // Can vary play speed
  CDVSD_CAP_CAN_CUE             = $0800;       // Can read sequent. after break
                                               // Used for Cue, Pause, and Seek

type
  //** Information about the disc **
  mci_CD_RegDisc_Parms = record
    LowestTrackNum    : Byte;                  // lowest track number
    HighestTrackNum   : Byte;                  // highest track number
    UPC               : array[0..upc_Size-1] of Byte; // upc, 13 BCD + 4bit 0
    DiscID            : mci_CD_ID;             // Disc ID
  end;

  //** Information about each track **
  mci_CD_RegTrack_Rec = record
    TrackNum          : Byte;                  // track number
    ulStartAddr       : uLong;                 // starting address in MMTIME
    ulEndAddr         : uLong;                 // ending address
    TrackControl      : Byte;                  // track control information
  end;

  //** Track information, used to verify address **
  mci_CD_RegTracks_Parms = record
   TrackRecArr        : ^mci_CD_RegTrack_Rec;  // ptr to array of track recs
   ulBufSize          : uLong;                 // size of buffer
  end;

  // Environment settings to save and restore
  mciDrv_CD_Save_Parms = record
    ulPosition        : uLong;                 // current position in MMTIME
    ulEndPlay         : uLong;                 // end play position
    ulMode            : uLong;                 // Play mode: playing, paused, etc.
    ulLevel           : uLong;                 // volume levels
    ulVSDData         : uLong;                 // Extra VSD data storage area
  end;

const
  // Read Long (2352-Byte) Sectors

  // Flag for the MCIDRV_CD_READ_Long message
  //   Default addressing mode for the ulFrom field is Hardware Red Book.
  //   Absolute sector addressing for ISO-9660, or High Sierra Group
  //   requires a flag, as does an MMTIME address.

  MCI_CD_READLong_HSG           = $00000100;
  MCI_CD_READLong_MMTIME        = $00000200;

type
  mci_CD_ReadLong_Parms = record
    ulFrom            : uLong;                 // read from this position
    usCount           : UShort;                // Number of sectors to read
    pReturn           : Pointer;               // Pointer to return buffer
    ulRetSize         : uLong;                 // Return buffer size
  end;

const
  // CD Table INI file, MMPMCD.INI, values

  // Capability Flags I from the CD drive look-up table, MMPMCD.INI
  CDHW_CAP_CAN_EJECT            = $00000001;  // Can software eject disc
  CDHW_CAP_CAN_LOCK             = $00000002;  // Can lock drive/disable eject
  CDHW_CAP_READS_RAW            = $00000004;  // Can read raw sectors
  CDHW_CAP_CAN_WRITE            = $00000008;  // Can write to disc
  CDHW_CAP_CAN_PLAY             = $00000010;  // Can play CD-DA tracks
  CDHW_CAP_CAN_INTERLEV         = $00000020;  // Supports ISO-9660 interleaving
  CDHW_CAP_CAN_PREFETCH         = $00000080;  // Can prefetch internally
  CDHW_CAP_MANIP_AUDIO          = $00000100;  // Can manipulte audio channels
  CDHW_CAP_USES_REDBOOK         = $00000200;  // Can use Red Book mode
  CDHW_CAP_READS_XA             = $00000400;  // Can read CD-ROM/XA data
  CDHW_CAP_CONT_READS           = $00000800;  // Continues to read DA after stop
  CDHW_CAP_CAN_REVERSE          = $00001000;  // Can play in reverse
  CDHW_CAP_READS_CDDA           = $40000000;  // Can read CD-DA audio tracks

  // Capability Flags II from the CD drive look-up table, MMPMCD.INI
  CDHW_VOL_DEP_MASK             = $00000007;  // Volume dependency mask
  CDHW_VOL_DEP_NONE             = 0;  // Volume without dependency
  CDHW_VOL_DEP_HIGH             = 2;  // Volume is highest value
  CDHW_VOL_DEP_LOW              = 3;  // Volume is lowest value
  CDHW_VOL_DEP_LEFT             = 4;  // Volume is left volume
  CDHW_VOL_DEP_RIGHT            = 5;  // Volume is right volume
  CDHW_VOL_INDEP_MUTE           = $00000008;  // Mute has no dependency
  CDHW_CAP_LOCK_MOUNT           = $00000010;  // Can only lock when mounted
  CDHW_CAP_PLAY_VIDEO           = $00000020;  // Can play video
  CDHW_CAP_MODAL_ONLY           = $00000040;  // Stop req to interrupt PLAY
  CDHW_CAP_SUP_SEEK             = $00000080;  // Supports SEEK IOCTL
  CDHW_CAP_SUP_UPC              = $00000100;  // Supports UPC IOCTL
  CDHW_CAP_SUP_SUBCHAN          = $00000200;  // Supports sub-channel IOCTL
  CDHW_CAP_CAN_CLS_TRAY         = $00000400;  // Can close door/retract caddy
  CDHW_CAP_NO_STREAM            = $00001000;  // Cannot stream CD-DA when PDD
                                          //   says it can
  CDHW_CAP_VAR_PLAY             = $80000000;  // Supports variable speeds

// INI file record structure
  CDINI_APPSIZE                 = 8;           // Application name size
  CDINI_KEYSIZE                 = 16;          // Key name size
  CDINI_VSD_NAME_SIZE           = 8;           // size of file name
  VOLUME_CONTROL                = 101;         // num of values, 0% - 100%

type
  mmpmCD_Rec = record
    usEntryVer        : UShort;                // Entry version
    ulCaps1           : uLong;                 // Capability flag I
    ulCaps2           : uLong;                 // Capability flag II
    VSDName           : array[0..CDINI_VSD_NAME_SIZE-1] of Char; // DLL name for VSD
    ulMinStart        : uLong;                 // Min starting addr, 0x00MMSSFF
    usVolCnt          : UShort;                // volume level counter
    ausVolValues      : array[0..Volume_Control] of UShort;  // volume control values
  end;

{----[ MCDOS2 ]----}

const
  // Multimedia Extensions MCD structures and definitions

  LIST_LEN                      = 8;

  LINE_IN_ON                    = $00000001;
  MIC_ON                        = $00000002;
  LINE_OUT_ON                   = $00000004;

type
  // RIFF to ACPA Mode conversion Table
  RiffTable = record
    ulDataType        : uLong;
    ulAUDIODDMode     : uLong;
  end;

  mci_Port_list = record
    ulDevType         : uLong;
    ulDevNum          : uLong;
  end;

type
  // Amp/Mixer instance structure declaration
  mci_Amp_Instance = record
    szDeviceName             : array[0..127] of Char;
    szDriverName             : array[0..15] of Char;
    hFile                    : HFILE;
    usDeviceID               : UShort;
    ulGlobalFile             : uLong;

    usMasterVolume           : UShort;
    lLeftVolume              : Long;
    lRightVolume             : Long;
    lVolumeDelay             : Long;

    lBalance                 : Long;

    lBalanceDelay            : Long;

    lBass                    : Long;

    lTreble                  : Long;

    lPitch                   : Long;
    lGain                    : Long;

    lSRate                   : Long;
    lBitsPerSRate            : Long;
    lBsize                   : Long;
    sMode                    : Short;
    sChannels                : Short;
    ulFlags                  : uLong;
    lMonitor                 : Long;
    lInput                   : Long;
    lOutput                  : Long;
    ulOperation              : uLong;
    ulGainLevel              : uLong;


    ulStoreRVolume           : uLong;
    ulStoreLVolume           : uLong;


    ulDosOpened              : uLong;
    ulInitOpen               : uLong;
    ulMasterVolume           : uLong;
    ulActive                 : uLong;
    lStoreSRate              : Long;
    lStoreBitsPerSRate       : Long;
    ulStoreOperation         : uLong;
    sStoreMode               : Short;
    sStoreChannels           : Short;
    ulSetAmpDefaults         : uLong;
    ulDefaultsSet            : uLong;

    ulOutputDev              : uLong;
    ulInputDev               : uLong;
    ulResourcesUsed          : uLong;
    ulRestoreNotify          : uLong;
    ulCallback               : uLong;
    sUserParm                : Short;
    lNotifyFlag              : Long;

// NEEDS THINKING!
//  Long  ( * APIENTRY pfnAUDIOIF) ( Pointer, Long, Long, Long, Long);
    hmtxInstanceSem          : HMTX;
    ulClass                  : uLong;
    ulBlockAlignment         : uLong;
    ulHardwareMode           : uLong;
    rInputList               : array[ 0..LIST_LEN ] of mci_Port_List;
    rOutputList              : array[ 0..LIST_LEN ] of mci_Port_List;
    ulNumInputs              : uLong;
    ulNumOutputs             : uLong;

    ulDataType               : uLong;
    ulSubType                : uLong;
    ulBytesPerBlock          : uLong;
    ulMMTimePerBlock         : uLong;

    // New resource management stuff
    pAudioModeData           : Pointer;      // ptr to dev. specific resource data
    pResourceDLL             : array[0..127] of Char;

    pProdInfo                : pChar;     // pointer to the product name
    ulDeviceID               : uLong;     // pointer to the device id.
    ulNumMappingRows         : uLong;     // num of RIFF->AUDIODD mapping modes
    ulMatch                  : uLong;
    pMapTable                : ^RiffTable; // additional RIFF->AUDIODD mappings

    ulNumDataTypes           : uLong;     // number of datatypes to check
    pDataTypeTable           : Pointer;
    fMute                    : Bool;
    ulResourceID             : uLong;     // offset in the resource dll to use
    ulConnDefaults           : uLong;     // Default values for connectors
  end;
  pmci_Amp_Instance = ^mci_Amp_Instance;

{----[ OS2MIXER ]----}

// Multimedia Mixer Software Development Kit Include File

type
  hMixer  = uLong;
  phMixer = ^hMixer;

  MixerLineInfo = record
    ulLength              : uLong;    //length of the struct
    ulNumChannels         : uLong;    // number of channels on input
    ulSupport             : uLong;    // supported functionality (MIXLINEINFO)
    ulConnectionsPossible : uLong;    // lines connectable to
    ulLine                : uLong;    // which line to operate on
  end;
  pMixerLineInfo = ^MixerLineInfo;

  LineConnections = record
    ulLength              : uLong;    // length of the struct
    ulConnection          : uLong;
    ulLine                : uLong;
    ulFlags               : uLong;
  end;
  pLineConnections = ^LineConnections;

  MixerControl = record
    ulLength              : uLong;    // length of the struct
    ulLine                : uLong;
    ulControl             : uLong;
    ulSetting             : uLong;
  end;
  pMixerControl = ^MixerControl;

const
  // -- need masteraudio command for the following.
  // flags for MIXERLINEINFO ulSupport field
  MIX_BALANCE                   = MCI_AMP_SET_BALANCE;     // separate balance volume control
  MIX_ALC                       = MCI_AMP_SET_ALC;         // supports Auto Level Control
  MIX_MONITOR                   = MCI_AMP_SET_MONITOR;     // supports Monitor Control
  MIX_CROSSOVER                 = MCI_AMP_SET_CROSSOVER;   // supports crossover change
  MIX_LOUDNESS                  = MCI_AMP_SET_LOUDNESS;    // supports loudness equalization
  MIX_MUTE                      = MCI_AMP_SET_MUTE;        // supports channel mute
  MIX_REVERB                    = MCI_AMP_SET_REVERB;      // supports reverb
  MIX_STEREOENHANCE             = MCI_AMP_SET_STEREOENHANCE;// supports stereo enhance
  MIX_CUSTOM1                   = MCI_AMP_SET_CUSTOM1;     // supports custom effect #1
  MIX_CUSTOM2                   = MCI_AMP_SET_CUSTOM2;     // supports custom effect #2
  MIX_CUSTOM3                   = MCI_AMP_SET_CUSTOM3;     // supports custom effect #3
  MIX_LRVOLUME                  = MCI_AMP_SET_LRVOLUME;    // separate left-right volume control
  MIX_BASS                      = MCI_AMP_SET_BASS;        // supports Bass
  MIX_MID                       = MCI_AMP_SET_MID;         // supports Mid
  MIX_TREBLE                    = MCI_AMP_SET_TREBLE;      // supports Treble
  MIX_PITCH                     = MCI_AMP_SET_PITCH;       // supports pitch modifications
  MIX_GAIN                      = MCI_AMP_SET_GAIN;        // supports gain modifications
  MIX_CHORUS                    = MCI_AMP_SET_CHORUS;      // supports Bass
  MIX_VOLUME                    = MCI_AMP_SET_VOLUME;      // supports volume controls

  MIX_STEREO_OFF                = $00000000;
  MIX_STEREO_STUDIO             = $40004000;
  MIX_STEREO_HALL               = $80008000;
  MIX_STEREO_STADIUM            = $c000c000;

  MCI_STEREO_OFF                = $00000000;
  MCI_STEREO_STUDIO             = $00000001;
  MCI_STEREO_HALL               = $00000002;
  MCI_STEREO_STADIUM            = $00000004;


  MIX_LOUDNESS_OFF              = $00000000;
  MIX_LOUDNESS_ON               = $FFFFFFFF;

  MCI_LOUDNESS_OFF              = $00000000;
  MCI_LOUDNESS_ON               = $00000001;

  // ERROR MESSAGES
  MIXERR_BASE                   = 512;

  MIXERR_NOERR                  = 0;
  MIXERR_INVALIDHANDLE          = MIXERR_BASE+0;
  MIXERR_INVALIDINPUT           = MIXERR_BASE+1;
  MIXERR_INVALIDOUTPUT          = MIXERR_BASE+2;
  MIXERR_NOTSUPPORTED           = MIXERR_BASE+7;

  // INPUT LINES
  // SOURCES
  IN_SYNTHESIZER                = 0;
  IN_MIXER                      = 1;
  IN_EXTERNAL                   = 2;
  IN_INTERNAL                   = 3;
  IN_MICROPHONE                 = 4;
  IN_PCM                        = 5;
  IN_PC_SPEAKER                 = 6;

  // SINKS
  OUT_AMPLIFIER                 = 0;
  OUT_PCM                       = 1;

  // SOURCES
  SOURCE_SYNTHESIZER            = $000000001;
  SOURCE_LINE                   = $000000002;
  SOURCE_INTERNAL_AUDIO         = $000000004;
  SOURCE_MICROPHONE             = $000000008;
  SOURCE_WAVE                   = $000000010;
  SOURCE_PC_SPEAKER             = $000000020;

  // SINKS
  SINK_LINE_OUT                 = $000000001;
  SINK_SPEAKER                  = $000000002;
  SINK_HEADPHONES               = $000000004;
  SINK_NULL                     = $000000008;
  SINK_ALL                      = $000000010;

{----[ SHDD ]----}

// Multimedia Extensions Stream Handler Device Driver Interfaces
// Block defintions.

type
  shdfn = pointer;
  ddcmdfn = pointer;

const
  // DDCMD Defines
  DDCMD_SETUP                   = 0;
  DDCMD_READ                    = 1;
  DDCMD_WRITE                   = 2;
  DDCMD_STATUS                  = 3;
  DDCMD_CONTROL                 = 4;
  DDCMD_REG_STREAM              = 5;
  DDCMD_DEREG_STREAM            = 6;

type
  ddCmdCommon = record
    ulFunction        : uLong;                 // Function requested by SH
    Stream            : hStream;               // data stream instance
  end;
  pddCmdCommon = ^ddCmdCommon;

  ddCmdSetup = record
    ulFunction        : uLong;                 // Function requested by SH
    hStream           : HSTREAM;
    pSetupParm        : Pointer;               // see SETUP_PARM struct
    ulSetupParmSize   : uLong;                 // see SETUP_PARM struct
  end;
  pddCmdSetup = ^ddCmdSetup;

  // SETUP_PARM structure
  Setup_Parm = record                          //  DDCMDSETUP parameter block
    ulStreamTime      : uLong;                 // stream time in milliseconds
    ulFlags           : uLong;                 // various flags (input/output)
    // NOTE: new fields will be added here
  end;
  pSetup_Parm = ^Setup_Parm;

const
  // ulFlag defines
  SETUP_RECURRING_EVENTS        = $00000001;
                // the device driver sets this flag on return from the
                // DDCMD_SETUP command if the device driver assumes events
                // are recurring events---in this case, the stream handler
                // will not have to re-enable a recurring event each time
                // the event occurs by sending a DDCMD_CONTROL command to
                // the device driver.  this is useful when CUE_TIME or
                // DATA_CUE events are expected to be used as RECURRING

type
  ccCmdReadWrite = record
    ulFunction        : uLong;                 // Function requested by SH
    hStream           : HSTREAM;
    pBuffer           : Pointer;
    ulBufferSize      : uLong;
    pProcessLin       : Pointer;
  end;
  pccCmdReadWrite = ^ccCmdReadWrite;
  ppccCmdReadWrite = ^pccCmdReadWrite;

  ccCmdStatus = record
    ulFunction        : uLong;                 // Function requested by SH
    hStream           : HSTREAM;
    pStatus           : Pointer;               // (output)ptr to current position time
    ulStatusSize      : uLong;                 // (output)size of position time
  end;
  pccCmdStatus = ^ccCmdStatus;

  // STATUS_PARM structure
  Status_Parm = record                         // DDCMDSTATUS parameter block
    ulTime            : uLong;                 // current position time in milliseconds
    // NOTE: new fields will be added here
  end;
  pStatus_Parm = ^Status_Parm;

  ddCmdControl = record
    ulFunction        : uLong;                 // Function requested by SH
    hStream           : HSTREAM;
    hEvent            : hEvent;                // used for EVENTS only
    ulCmd             : uLong;
    pParm             : Pointer;               // see CONTROL_PARM structure
    ulParmSize        : uLong;                 // see CONTROL_PARM structure
  end;
  pddCmdControl = ^ddCmdControl;

const
  // ulCmd defines
  DDCMD_START                   = 1;           // start device
  DDCMD_STOP                    = 2;           // stop device and return current position in pParm
  DDCMD_PAUSE                   = 3;           // pause device and return current position in pParm
  DDCMD_RESUME                  = 4;           // resume device
  DDCMD_ENABLE_EVENT            = 5;           // ask PDD to create this event
  DDCMD_DISABLE_EVENT           = 6;           // ask PDD to purge this event
  DDCMD_PAUSE_TIME              = 7;           // pause time keeping, but not the stream
  DDCMD_RESUME_TIME             = 8;           // resume time keeping.

type
  // CONTROL_PARM structure
  Control_Parm = record                        // DDCMDCONTROL parameter block
    ulTime            : uLong;                 // time in milliseconds
                                               // SH sets cuetime when ulCmd is ENABLE_EVENT
                                               // PDD returns current time for STOP, PAUSE
    evcb              : TIME_EVCB;
  end;
  pControl_Parm = ^Control_Parm;

  ddCmdRegister = record
    ulFunction        : uLong;                 // Function requested by SH
    hStream           : HSTREAM;               // Stream handle needed @ interrupt time
    ulSysFileNum      : uLong;                 // Device Handle so pdd can map device instance to hstream
    pSHDEntryPoint    : SHDFN;                 // Stream handler entry point
    ulStreamOperation : uLong;                 // SH input Record or play
    spcbkey           : SPCBKEY;
    ulBufSize         : uLong;                 // PDD output (optional) buffer size in bytes for SPCB
    ulNumBufs         : uLong;                 // PDD output (optional) # of buffers for SPCB
    ulAddressType     : uLong;                 // PDD output (required) addr ptr type to data buffer
    ulBytesPerUnit    : uLong;                 // PDD output (required)
    mmtimePerUnit     : MMTIME;                // PDD output (required)
    dcbAudio          : E_DCB;                 // SH input Device Control Block
    hid               : HID;                   // SH input stream handler id
  end;
  pddCmdRegister = ^ddCmdRegister;

const
  // ulStreamOperation  defines
  STREAM_OPERATION_MASK         = $C000;
  STREAM_OPERATION_CONSUME      = $8000;
  STREAM_OPERATION_PRODUCE      = $C000;

  // ulAddressType  defines
  // The PDD will tell the SH what type of address ptr it expects the data buffer
  // to be.  The SH will then request this address type to the SSM, so that the
  // SSM will send the correct type of each buffer request.
  ADDRESS_TYPE_VIRTUAL          = 0;
  ADDRESS_TYPE_PHYSICAL         = 1;              //default
  ADDRESS_TYPE_LINEAR           = 2;

type
  ddCmdDeregister = record
    ulFunction        : uLong;                 // Function requested by SH
    Stream            : hStream;               // Stream handle needed @ interrupt time
  end;
  pddCmdDeregister = ^ddCmdDeregister;

//*** RING 0 Stream Handler SHD Interfaces                                **

const
  // RING 0 Stream Handler  SHD's:
  SHD_REPORT_INT                = 0;           // PDD reports interrupt has arrived
  SHD_REPORT_EVENT              = 1;           // PDD reports cuetime has arrived

type
  shd_Common = record
    ulFunction        : uLong;                 // Function requested by PDD
    Stream            : hStream;               // Stream handle needed @ interrupt time
  end;
  pshd_Common = ^shd_Common;

  shd_ReportInt = record
    ulFunction        : uLong;                 // Function requested by PDD
    hStream           : HSTREAM;               // so SH knows which stream to process
    pBuffer           : Pointer;               // return ptr to last used buffer
    ulFlag            : uLong;                 // reason for interrupt
    ulStatus          : uLong;                 // rc or bytes read/written
    ulStreamTime      : uLong;                 // time in milliseconds of stream position
  end;
  pshd_ReportInt = ^shd_ReportInt;

const
  // ulFlag settings
  ERROR                         = $80;
  STREAM_STOP_NOW               = $40;
  SHD_READ_COMPLETE             = 1;
  SHD_WRITE_COMPLETE            = 2;

type
  shd_ReportEvent = record
    ulFunction        : uLong;                 // Function requested by PDD
    hStream           : HSTREAM;               // so SH knows which stream to process
    hEvent            : hEvent;                // event handle pass back to stream handler
    ulStreamTime      : uLong;                 // time in milliseconds of stream position
  end;
  pshd_ReportEvent = ^shd_ReportEvent;


//*** RING 3 Stream Handler SHD Interfaces                                **

const
  // RING 3 Stream Handler  SHD's: (Uses SpiSendMsg as interface)
  SHC_REPORT_INT                = $80000000;   // ulMsgType for SHD_REPORT_INT
  SHC_REPORT_EVENT              = $80000001;   // ulMsgType for SHD_REPORT_EVENT

type
  // MSG_REPORTINT Control Block.
  // pMsg field of SpiSendMsg api
  msg_ReportInt = record
    ulMsgLen          : uLong;                 // Length of structure
    pBuffer           : Pointer;               // return ptr to last used buffer
    ulFlag            : uLong;                 // reason for interrupt
    ulStatus          : uLong;                 // rc or bytes read/written
    ulStreamTime      : uLong;                 // time in milliseconds of stream position
  end;
  pmsg_ReportInt = ^msg_ReportInt;

   // For ulFlag defines, refer to the _shd_reportint_parm structure

type
  // MSG_REPORTEVENT Control Block.
  //  pMsg field of SpiSendMsg api
  msg_ReportEvent = record
    ulMsgLen          : uLong;                 // Length of structure
    hevent            : hEvent;                // event handle pass back to stream handler
    ulStreamTime      : uLong;                 // time in milliseconds of stream position
  end;
  pmsg_ReportEvent = ^msg_ReportEvent;

implementation

function mciPlayFile;                          external;
function mciPlayResource;                      external;
function mciRecordAudioFile;                   external;
function mciSendCommand;                       external;
function mciSendString;                        external;
function mciGetErrorString;                    external;
function mciMakeGroup;                         external;
function mciDeleteGroup;                       external;
function mciSetSysValue;                       external;
function mciQuerySysValue;                     external;
function mciGetDeviceID;                       external;

function SpiAssociate;                         external;
function SpiEnumerateHandlers;                 external;
function SpiGetHandler;                        external;
function SpiCreateStream;                      external;
function SpiSendMsg;                           external;
function SpiDestroyStream;                     external;
function SpiGetTime;                           external;
function SpiSeekStream;                        external;
function SpiStartStream;                       external;
function SpiStopStream;                        external;
function SpiDisableEvent;                      external;
function SpiEnableEvent;                       external;
function spiDisableSync;                       external;
function spiEnableSync;                        external;
function spiDetermineSyncMaster;               external;
function spiGetProtocol;                       external;
function spiInstallProtocol;                   external;
function spiEnumerateProtocols;                external;

function mdmDriverNotify;                      external;

function mmioRemoveElement;                    external;
function mmioFindElement;                      external;
function mmioAdvance;                          external;
function mmioAscend;                           external;
function mmioClose;                            external;
function mmioCreateChunk;                      external;
function mmioDescend;                          external;
function mmioFlush;                            external;
function mmioGetInfo;                          external;
function mmioGetLastError;                     external;
function mmioInstallIOProc;                    external;
function mmioIOProc;                           external;
function mmioOpen;                             external;
function mmioRead;                             external;
function mmioSeek;                             external;
function mmioSendMessage;                      external;
function mmioSetBuffer;                        external;
function mmioSetInfo;                          external;
function mmioStringToFourCC;                   external;
function mmioWrite;                            external;

function mmioCFOpen;                           external;
function mmioCFClose;                          external;
function mmioCFGetInfo;                        external;
function mmioCFSetInfo;                        external;
function mmioCFFindEntry;                      external;
function mmioCFAddEntry;                       external;
function mmioCFChangeEntry;                    external;
function mmioCFDeleteEntry;                    external;
function mmioCFAddElement;                     external;
function mmioCFCopy;                           external;

function mmioQueryFormatCount;                 external;
function mmioGetFormats;                       external;
function mmioGetFormatName;                    external;
function mmioIdentifyFile;                     external;
function mmioQueryHeaderLength;                external;
function mmioGetHeader;                        external;
function mmioSetHeader;                        external;
function mmioIniFileHandler;                   external;
function mmioIdentifyStorageSystem;            external;
function mmioDetermineSSIOProc;                external;
function mmioQueryIOProcModuleHandle;          external;
function mmioCFCompact;                        external;
function mmioMigrateIniFile;                   external;
function mmioIniFileCODEC;                     external;
function mmioSet;                              external;
function mmioQueryCODECName;                   external;
function mmioQueryCODECNameLength;             external;
function mmioLoadCODECProc;                    external;
function mmioGetData;                          external;

function WinSecondaryWindow;                   external;
function WinLoadSecondaryWindow;               external;
function WinProcessSecondaryWindow;            external;
function WinCreateSecondaryWindow;             external;
function WinDefaultSize;                       external;
function WinInsertDefaultSize;                 external;
function WinQuerySecondaryhwnd;                external;
function WinSecondaryMessageBox;               external;
function WinDismissSecondaryWindow;            external;
function WinDestroySecondaryWindow;            external;
function WinDefSecondaryWindowProc;            external;

function WinRegisterGraphicButton;             external;

Function DiveQueryCaps;                        external;
Function DiveOpen;                             external;
Function DiveSetupBlitter;                     external;
Function DiveBlitImage;                        external;
Function DiveClose;                            external;
Function DiveAcquireFrameBuffer;               external;
Function DiveSwitchBank;                       external;
Function DiveDeacquireFrameBuffer;             external;
Function DiveCalcFrameBufferAddress;           external;
Function DiveAllocImageBuffer;                 external;
Function DiveFreeImageBuffer;                  external;
Function DiveBeginImageBufferAccess;           external;
Function DiveEndImageBufferAccess;             external;
Function DiveSetDestinationPalette;            external;
Function DiveSetSourcePalette;                 external;

initialization
  FourCC_RIFF := mmioFourCC( 'R', 'I', 'F', 'F' );
  FourCC_LIST := mmioFourCC( 'L', 'I', 'S', 'T' );
  FourCC_MEM  := mmioFourCC( 'M', 'E', 'M', ' ' );
  FourCC_DOS  := mmioFourCC( 'D', 'O', 'S', ' ' );
  FourCC_BND  := mmioFourCC( 'B', 'N', 'D', ' ' );
  FourCC_FREE := mmioFourCC( 'F', 'R', 'E', 'E' );
  FourCC_DEL  := mmioFourCC( 'D', 'E', 'L', ' ' );
  FourCC_CTOC := mmioFourCC( 'C', 'T', 'O', 'C' );
  FourCC_CGRP := mmioFourCC( 'C', 'G', 'R', 'P' );
  FourCC_CF   := mmioFourCC( 'C', 'F', ' ', ' ' );
  FOURCC_ULTI := mmioFOURCC( 'U', 'L', 'T', 'I' );
  FourCC_RT21 := mmioFOURCC( 'R', 'T', '2', '1' );
  FourCC_DIB  := mmioFOURCC( 'D', 'I', 'B', ' ' );
end.

[ RETURN TO DIRECTORY ]