devxlogo

ExecuteMCICommand – Executing a MCI command

ExecuteMCICommand – Executing a MCI command

 Shared Function _    mciSendString(ByVal lpstrCommand As String, ByVal lpstrReturnString As _    String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As _    IntegerEnd Function' helper routine; executes a MCI command ' commandString is the command to execute' deviceAlreadyOpened must be set to true if the caller has already opened the ' deviceSub ExecuteMCICommand(ByVal commandString As String, ByVal deviceAlreadyOpened _    As Boolean)    Dim returnCode As Integer = mciSendString(commandString, vbNullString, 0, 0)    ' if the return code is not 0, an error occurred    If returnCode  0 Then        ' close the device if necessary        If deviceAlreadyOpened Then            commandString = "close AVIFile"            mciSendString(commandString, vbNullString, 0, 0)        End If        ' throw a custom exception        Throw New MCICommandException(returnCode)    End IfEnd Sub' helper custom exception' motes: requires the GetMCIErrorString functionClass MCICommandException    Inherits Exception    Public Sub New(ByVal errorCode As Integer)        MyBase.New(GetMCIErrorString(errorCode))    End SubEnd Class

devx-admin

Share the Post: