Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

open command

The open command initializes a device. All MCI devices recognize this command.

To send this command, call the mciSendString function with the lpszCommand parameter set as follows.


_stprintf_s(
  lpszCommand, 
  TEXT("open %s %s %s"), 
  lpszDevice, 
  lpszOpenFlags, 
  lpszFlags
); 

Parameters

lpszDevice

Identifier of an MCI device or device driver. This can be either a device name (as given in the registry or the SYSTEM.INI file) or the filename of the device driver. If you specify the filename of the device driver, you can optionally include the .DRV extension, but you should not include the path to the file.

lpszOpenFlags

Flag that identifies what to initialize. The following table lists device types that recognize the open command and the flags used by each type.

ValueMeaningMeaning
cdaudioalias device_aliassharabletype device_type
digitalvideoalias device_aliaselementnamenostatic parent hwndsharablestyle child style overlapped style popup style style_typetype device_type
overlayalias device_aliasparent hwndsharable style childstyle overlapped style popup style style_typetype device_type
sequenceralias device_alias sharabletype device_type
vcralias device_aliassharabletype device_type
videodiskalias device_aliassharabletype device_type
waveaudioalias device_aliasbuffer buffer_sizesharable type device_type

 

The following table lists the flags that can be specified in the lpszOpenFlags parameter and their meanings.

ValueMeaning
alias device_aliasSpecifies an alternate name for the given device. If specified, it must be used as the device_id in subsequent commands.
elementnameSpecifies the name of the device element (file) loaded when the device opens.
buffer buffer_sizeSets the size, in seconds, of the buffer used by the waveform-audio device. The default size of the buffer is set when the waveform-audio device is installed or configured. Typically the buffer size is set to 4 seconds. With the MCIWAVE device, the minimum size is 2 seconds and the maximum size is 9 seconds.
parent hwndSpecifies the window handle of the parent window.
sharableInitializes the device or file as sharable. Subsequent attempts to open the device or file fail unless you specify "sharable" in both the original and subsequent open commands.

MCI returns an invalid device error if the device is already open and not sharable.

The MCISEQ sequencer and MCIWAVE devices do not support shared files.

style childOpens a window with a child window style.
style overlappedOpens a window with an overlapped window style.
style popupOpens a window with a pop-up window style.
style style_typeIndicates a window style.
type device_typeSpecifies the device type of a file.

 

lpszFlags

Can be "wait", "notify", or both. For more information about these flags, see The Wait, Notify, and Test Flags.

Return Value

Returns zero if successful or an error otherwise.

Remarks

MCI reserves "cdaudio" for the CD audio device type, "videodisc" for the videodisc device type, "sequencer" for the MIDI sequencer device type, "AVIVideo" for the digital-video device type, and "waveaudio" for the waveform-audio device type.

As an alternative to the "type" flag, MCI can select the device based on the extension used by the file, as recorded in the registry or the [mci extension] section of the SYSTEM.INI file.

MCI can open AVI files by using a file-interface pointer or a stream-interface pointer. To open a file by using either type of interface pointer, specify an at sign (@) followed by the interface pointer in place of the file or device name for the lpszDevice parameter. For more information about the file and stream interfaces, see " AVIFile Functions and Macros."

The following command opens the "mysound" device.

open new type waveaudio alias mysound buffer 6

With device name "new", the waveform driver prepares a new waveform resource. The command assigns the device alias "mysound" and specifies a 6-second buffer.

You can eliminate the "type" flag if you combine the device name with the filename. MCI recognizes this combination when you use the following syntax:

device_name ! element_name

The exclamation point separates the device name from the filename. The exclamation point should not be delimited by white spaces.

The following example opens the RIGHT.WAV file using the "waveaudio" device.

open waveaudio!right.wav

The MCIWAVE driver requires an asynchronous waveform-audio device.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

See also

MCI
MCI Command Strings

 

 

Community Additions

Show:
© 2014 Microsoft