dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB7
Expertise: Advanced
May 12, 2003

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


ExecuteMCICommand - Executing a MCI command

<System.Runtime.InteropServices.DllImport("winmm.dll")> Shared Function _
    mciSendString(ByVal lpstrCommand As String, ByVal lpstrReturnString As _
    String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As _
    Integer
End 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 
' device

Sub 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 If
End Sub

' helper custom exception
' motes: requires the GetMCIErrorString function

Class MCICommandException
    Inherits Exception

    Public Sub New(ByVal errorCode As Integer)
        MyBase.New(GetMCIErrorString(errorCode))
    End Sub
End Class
Alberto Falossi
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date