Freigeben über


MCI_OPEN

The MCI_OPEN command initializes a device or file. All devices recognize this command.

To send this command, call the mciSendCommand function with the following parameters.

MCIERROR mciSendCommand(
  MCIDEVICEID wDeviceID, 
  MCI_OPEN, 
  DWORD dwFlags, 
  (DWORD) (LPMCI_OPEN_PARMS) lpOpen
);

Parameters

wDeviceID

Device identifier of the MCI device that is to receive the command message.

dwFlags

MCI_NOTIFY or MCI_WAIT. For information about these flags, see The Wait, Notify, and Test Flags.

lpOpen

Pointer to an MCI_OPEN_PARMS structure. (Devices with extended command sets might replace this structure with a device-specific structure.)

Return Values

Returns zero if successful or an error otherwise.

Remarks

The MCI_OPEN_TYPE flag must be used whenever a device is specified in the mciSendCommand function. If you open a device by specifying a device-type constant, you must specify the MCI_OPEN_TYPE_ID flag in addition to MCI_OPEN_TYPE. For a list of device-type constants, see MCI Device Types.

If the MCI_OPEN_SHAREABLE flag is not specified when a device or file is initially opened, all subsequent MCI_OPEN commands to the device or file will fail. If the device or file is already open and this flag is not specified, the call will fail even if the first open command specified MCI_OPEN_SHAREABLE. Files opened for the MCISEQ.DRV and MCIWAVE.DRV devices are nonshareable.

Case is ignored in the device name, but there cannot be leading or trailing blanks.

To use automatic type selection (via the entries in the registry), assign the filename and file extension to the lpstrElementName member of the structure identified by lpOpen, set the lpstrDeviceType member to NULL, and set the MCI_OPEN_ELEMENT flag.

The following additional flags apply to all devices supporting MCI_OPEN:

MCI_OPEN_ALIAS

An alias is included in the lpstrAlias member of the structure identified by lpOpen.

MCI_OPEN_SHAREABLE

The device or file should be opened as shareable.

MCI_OPEN_TYPE

A device type name or constant is included in the lpstrDeviceType member of the structure identified by lpOpen.

MCI_OPEN_TYPE_ID

The low-order word of the lpstrDeviceType member of the structure identified by lpOpen contains a standard MCI device type identifier and the high-order word optionally contains the ordinal index for the device. Use this flag with the MCI_OPEN_TYPE flag.

The following additional flags apply to compound devices:

MCI_OPEN_ELEMENT

A filename is included in the lpstrElementName member of the structure identified by lpOpen.

MCI_OPEN_ELEMENT_ID

The lpstrElementName member of the structure identified by lpOpen is interpreted as a DWORD value and has meaning internal to the device. Use this flag with the MCI_OPEN_ELEMENT flag.

The following additional flags are used with the digitalvideo device type:

MCI_DGV_OPEN_NOSTATIC

The device should reduce the number of static (system) colors in the palette. This increases the number of colors available for rendering the video stream. This flag applies only to devices that share a palette with Windows.

MCI_DGV_OPEN_PARENT

The parent window handle is specified in the hWndParent member of the structure identified by lpOpen.

MCI_DGV_OPEN_WS

A window style is specified in the dwStyle member of the structure identified by lpOpen.

MCI_DGV_OPEN_16BIT

Indicates a preference for 16-bit MCI device support.

MCI_DGV_OPEN_32BIT

Indicates a preference for 32-bit MCI device support.

For digital-video devices, the lpOpen parameter points to an MCI_DGV_OPEN_PARMS structure.

The following additional flags are used with the overlay device type:

MCI_OVLY_OPEN_PARENT

The parent window handle is specified in the hWndParent member of the structure identified by lpOpen.

MCI_OVLY_OPEN_WS

A window style is specified in the dwStyle member of the structure identified by lpOpen. The dwStyle value specifies the style of the window that the driver will create and display if the application does not provide one. The style parameter takes an integer that defines the window style. These constants are the same as the standard window styles (such as WS_CHILD, WS_OVERLAPPEDWINDOW, or WS_POPUP).

For video-overlay devices, the lpOpen parameter points to an MCI_OVLY_OPEN_PARMS structure.

The following additional flag is used with the waveaudio device type:

MCI_WAVE_OPEN_BUFFER

A buffer length is specified in the dwBufferSeconds member of the structure identified by lpOpen.

For waveform-audio devices, the lpOpen parameter points to an MCI_WAVE_OPEN_PARMS structure. The MCIWAVE driver requires an asynchronous waveform-audio device.

Requirements

**  Windows NT/2000/XP:** Included in Windows NT 3.1 and later.
**  Windows 95/98/Me:** Included in Windows 95 and later.
**  Header:** Declared in Mmsystem.h; include Windows.h.

See Also

MCI, MCI Commands, CreateWindow, MCI_DGV_OPEN_PARMS, MCI_OPEN_PARMS, MCI_OVLY_OPEN_PARMS, MCI_WAVE_OPEN_PARMS, mciSendCommand