Tutorials to .com

Tutorials to .com » Software » Vb » MCI Command String Overview

MCI Command String Overview

Print View , by: iSee ,Total views: 62 ,Word Count: 1915 ,Date: Tue, 14 Jul 2009 Time: 3:23 AM

MCI Command String Overview

(Note: In this paper, in July 2000, whichever is the MSDN explanation)

MCI Command String is a multimedia device interface. Through it, we can open a multimedia file, such as mp3, VCD files, Mpeg4 file format and so on, and it play, pause, shut down operations and so on. Boy now had the privilege to brief Members on the MCI Command String to use.

MCI Command String is mciExecute or mciSendString through the implementation of two functions. Statement of these two functions are as follows:

Private Declare Function mciExecute Lib "winmm.dll" Alias "mciExecute" (ByVal lpstrCommand As String) As Long

Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

These two functions have a parameter called lpstrCommand, the parameters that we are to introduce the MCI Command String. MciSendString function of which there are three parameters, lpstrReturnString is a string that is used to receive the information back to mciSendString function (for example, we lpstrCommand in order to allow function to return the equipment to open the document type, then the function of the type of device they Information stored in this parameter.); uReturnLength parameters used to specify the length of lpstrReturnString parameters; hwndCallback is receiving "wait", "notify" handle window messages in Visual Basic when the call parameters can be set to 0.

If you order the implementation of an error, function mciExecute will directly pop up a dialog box, suggesting that the cause of the problem. The function will return mciSendString a ErrorCode (error code), the specific meaning of the code that you can refer to MSDN directory "Platform SDK \ Graphics and Multimedia Services \ Windows Multimedia \ Multimedia Reference \ Multimedia Constants \ MCIERR Return Values". You can choose according to the specific circumstances of the use of which in the end to implement the MCI command function. For example, when used in debugging mciExecute, for quick access to the wrong reasons, to be published in the proceedings mciSendString function, so that the procedure has been set up to deal with the error trap errors, in order to avoid the error of frequent users felt tired .

In a familiar of the two functions, we will be able to enter the subject - MCI Command String of.

MCI Command String command format is this: lpszCommand lpszDevice lpszCommandFlag lpazFlag

mci command lpszCommand is, for example, open, play, stop, close and so on.

lpszDevice is the device name (or file name). For example, we use the following procedure to open the My Documents in Music01.dat documents, and "alias" parameter to set an alias OpenFile:

dim lReturn as long (1)

lReturn = mciExecute ( "open C: \ Mydocu ~ 1 \ Music01.dat alias OpenFile type MPEGVideo") (2)

Then, in subsequent lpszDevice of MCI Command String parameters must be specified for OpenFile. For example, the code to close the document is as follows:

lReturn = mciExecute ( "close OpenFile") (3)

If we do not have to set an alias to open the file, then after the call in the MCI Command String parameters lpszDevice plus path name DOS file name. Examples are as follows:

dim lReturn as long (4)

lReturn = mciExecute ( "open C: \ Mydocu ~ 1 \ Music01.dat type MPEGVideo") (5)

lReturn = mciExecute ( "close C: \ Mydocu ~ 1 \ Music01.dat type MPEGVideo") (6)

As can be seen from here, set the alias is to reduce the benefits of the code input.

Mci command is LpszCommandFlag parameters. As indicated in the code (2), "alias OpenFile" and "type MPEGVideo" command is "open" parameters. Mci command is usually a number of parameters at least as many as several dozen.

LpazFlag can be designated as a "wait" or "notity". If the "wait", then after the implementation of mci command will be sent to the parent form MCI_WAIT news, "notity" message is sent MCI_NOTIFY. This parameter in the use of Visual Basic in little.

In the first statement about Microsoft's support for the type of multimedia equipment total cdaudio, dat, digitalvideo, other, overlay, scanner, sequencer, vcr, videodisc, waveaudio ten (Note: Microsoft does not support the file format RealPlay. You can use the following code has been open access to the type of document: lReturn = mciSendString ( "capability lpszDevice device type", sReturn, 32,0)). As for what kind of equipment in support of what the parameters, you can find in MSDN keyword "MCI Command Strings", the selected list of orders, in which the HTML help files in a table usually tell you what equipment to support what the parameters or there is information in the first paragraph tells you what equipment to support the order.

Well, now we have another fan demand, and deserve to die, but also a strong command parameter mci introduction of a system. (This article is open only to introduce a common command parameters, the parameters of other commands and then have the opportunity to introduce to you boy.)


The order to open a multimedia file. All the devices support this command. Mci command in any implementation of the former, one must open the multimedia files in order to initialize the device.

The significance of the order of several parameters as follows: alias device_alias - To open the file specified alias; shareable - whether or not to share open, If you do not specify this parameter, then open the way not to share, that is, open a multimedia file, other programs can not open it, if you specify the parameters, are open to share; type device_type - specify the file registered in the Windows multimedia file name (Note: Windows in the multimedia file name registration and equipment were not the same type, equipment type, only 10 kinds of the above-mentioned type, and Windows in the registration of multimedia files, please view the C: \ Windows \ win.ini file [mci extensions] section.), such as MPEGVideo, AVIVideo, waveaudio etc., MPEGVideo, AVIVideo types of files are in fact equipment digitalvideo.

For the open command, there are several aspects to be noted. First of all, with open command to open a file, the path to the file format must be DOS short path. You can use the API function to return to a path GetShortPathName of the format. The parameters of type device_type, complex equipment (eg: MPEGVideo) mci equipment will be automatically registered in the Windows of the extension (an extension to obtain the document in Windows in the type of registration, see the C: \ Windows \ win.ini file [mci extensions] section.) setting the parameters (so the C: \ Windows \ win.ini file [mci extensions] section of the extensions are listed, do not have to specify the parameters), but if equipment can not be obtained in accordance with its extension of the type of document, it must specify the parameters, If you do not specify will be prompted: "This is not a registered mci equipment", and simple equipment (such as CD track equipment, programmable control The recorded video player, programmable control of laser projection players) do not have to specify the parameters.

If the order has been successfully implemented, then the return value is 0. At this point, you can specify an alias with alias implementation of a wide range of mci command.

(Note: the following command function can be achieved, though exciting, but often you open the document in order to support the few.)

Break: the designation of a key to exit the current use of wait parameters mci command.

Capability: open access to the functions of equipment, such as whether the player can withdraw from, whether records.

Capture: Frame buffer data will be copied to the specified file.

Close: close the device, the release of memory.

Configure: displays a dialog box to set certain attributes of equipment.

Copy: Copy data to clipboard.

Cue: in the play or record prior to the execution of such order to accelerate the speed to play or record.

Cut: The data area will be cut to the clipboard.

Delete: to open from the multimedia files to delete data segment.

Freeze: the termination of the video input or output, the prohibition of the video stream obtained from the frame data buffer.

Info: access equipment, such as algorithms, copyright, the open file, UPC, etc..

List: video and audio back to the number and type.

Load: the format of the specified equipment to open a file. Similar to the function open.

Monitor: specify the current source, the default is the current source of the work area.

Paste: the contents of the clipboard to copy the work area.

Pause: pause the playback or recording.

Play: Ha ha, this command no more to be said.

Put: shows the source and purpose of the window display area.

Quality: custom audio or video quality level and the compression of static images (such as BMP, JPG).

Realize: custom palette image display window.

Record: there is no need to say any more.

Reserve: the work area for the distribution of equipment for the disk space.

Restore: a still image from the files are copied to the frame buffer.

Resume: continue to play or record.

Save: Save a document mci.

Seek: Orientation to the designated location and wait for the frame.

Set: set some parameters. (For example, the left-channel, optical switches, Time Format, etc.).

Setaudio: audio parameter settings. (Such as bass, treble, left and right channels)

Setvideo: set up video playback or capture parameters. (Such as brightness, contrast and gamma value.)

Status: open to return to the status information of the equipment.

Step: Set the slow release of the frame when the step, rewind or negative, units of frames / sec.

Stop: do not need to say any more.

Undo: Undo the most recent copy, cut, delete and paste command.

Unfreeze: Freeze operation of the anti-.

Update: read the current frame of data, and display window in the target or the target DC (device context).

Where: to obtain an order Put the source or target designated display area.

Window: window set up to play. Can use it to play for the other window settings window to remove the default window.

Visual Basic Tutorial Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.