How to use the mci
The MCI or MediaControlInterface allows you to play and record wave files, play cds and midi-files and a lot more!

Select the following code with the mouse and copy it into the general section of a form or modul.

--- 16 bit code begins here---
Declare Function mcisendstring Lib "MMSystem" (ByVal CommandStr$, ByVal ReturnStr$, ByVal ReturnLen%, ByVal hWndCallback%) As Long
--- 16 bit code ends here---

--- 32 bit code begins here---
Public 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
--- 32 bit code ends here---

--- code begins here---
Rem The declaration above has to be in one line!

Function MCISimpleCommand (CommandStr$) As Long

Dim MCISendTest As Long
Dim MCISendRet As String * 255
MCISendTest = mcisendstring(CommandStr$, MCISendRet, 255, 0)

If (Len(MCISendRet) = 0) Then
MCISendRet = "no return text"
End If
temp$ = MCISendRet

MCISimpleCommand = MCISendTest

End Function
---code ends here---

Use the following code to send commands to the mci:

---code begins here---
Dim ret As Long
ret = MCISimpleCommand("insert command here")
---code ends here---

Examples for mci-commands:
MCISimpleCommand "OPEN music.mid type sequencer alias MID"
MCISimpleCommand "PLAY MID"

Hint:
You can find a complete listing of the mci-commands in the visual basic help.

Go back to my vb-page