CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1

    Return information of mciSendString

    What information is returned by "status" command of mciCommand when called with mciSendString?
    I have called:

    NoError = mciSendString("status cdaudio media present", RS, len(RS), 0)



    As written in MM reference:
    Return Values
    Returns information in the lpstrReturnString parameter of mciSendString. The information is dependent on the request type.

    So what kind of return value should I expect?


  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Return information of mciSendString

    From Api-guide:
    Returns zero if successful or an error otherwise. The low-order word of the returned doubleword value contains the error return value. If the error is device-specific, the high-order word of the return value is the driver identifier; otherwise, the high-order word is zero. For a list of possible error values, see Constants: MCIERR Return Values.

    To retrieve a text description of mciSendString return values, pass the return value to the mciGetErrorString function.

    The mciGetErrorString function retrieves a string that describes the specified MCI error code.
    Example:

    private Const MCI_OPEN = &H803
    private Const MCI_OPEN_TYPE = &H2000&
    private Const MCI_OPEN_SHAREABLE = &H100&
    private Const MCI_SET = &H80D
    private Const MCI_SET_DOOR_OPEN = &H100&
    private Const MCI_CLOSE = &H804
    private Type MCI_OPEN_PARMS
    dwCallback as Long
    wDeviceID as Long
    lpstrDeviceType as string
    lpstrElementName as string
    lpstrAlias as string
    End Type
    private Declare Function mciSendCommand Lib "winmm.dll" Alias "mciSendCommandA" (byval wDeviceID as Long, byval uMessage as Long, byval dwParam1 as Long, byref dwParam2 as Any) as Long
    private Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (byval dwError as Long, byval lpstrBuffer as string, byval uLength as Long) as Long
    Dim openParams as MCI_OPEN_PARMS
    private Sub Form_Load()
    'KPD-Team 2001
    'URL: http://www.allapi.net/
    '[email protected]
    Dim lRet as Long
    'initialize the structure
    openParams.wDeviceID = 0
    openParams.lpstrDeviceType = "cdaudio"
    'get the device ID
    lRet = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE Or MCI_OPEN_SHAREABLE, openParams)
    'check for error
    If lRet <> 0 then
    'show error
    MsgBox GetMCIErrorString(lRet), vbCritical
    else
    'open the door of the CD-ROM drive
    lRet = mciSendCommand(openParams.wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, byval 0&)
    'check for errors
    If lRet <> 0 then MsgBox GetMCIErrorString(lRet), vbCritical
    End If
    'clean up
    mciSendCommand openParams.wDeviceID, MCI_CLOSE, 0, byval 0&
    End Sub
    private Function GetMCIErrorString(lErr as Long) as string
    'create a buffer
    GetMCIErrorString = Space$(255)
    'retrieve the error string
    mciGetErrorString lErr, GetMCIErrorString, len(GetMCIErrorString)
    'strip off the trailing spaces
    GetMCIErrorString = Trim$(GetMCIErrorString)
    End Function




    (I did not tested this, just copy and paste from Api-guide - a free tool)

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured