UP,
The mciSendString function sends a command string to an MCI device. The device that the command is sent to is specified in the command string. MCIERROR mciSendString(
  LPCTSTR lpszCommand,  
  LPTSTR lpszReturnString,  
  UINT cchReturn,       
  HANDLE hwndCallback   
);
 
Parameters
lpszCommand 
Address of a null-terminated string that specifies an MCI command string. For more information about the command strings, see Command Strings. 
lpszReturnString 
Address of a buffer that receives return information. If no return information is needed, this parameter can be NULL. 
cchReturn 
Size, in characters, of the return buffer specified by the lpszReturnString parameter. 
hwndCallback 
Handle of a callback window if the "notify" flag was specified in the command string. 
Return Values
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. QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in mmsystem.h.
  Import Library: Use winmm.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.

解决方案 »

  1.   

    你是不是要里面的MCISTRING内容呀
      

  2.   

    ´请在声明区中加入以下声明: ( 和 "开启及关闭CD-Rom的门" 相同的声明)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´在 Form 中加入二个 CommandButton,分别命名为 cmdPlay 及 cmdStop 并加入以下程序码:Sub cmdPlay_Click()
    Dim lRet As Long
    Dim nCurrentTrack As Integer
    ´开启装置
    lRet = mciSendString("open cdaudio alias cd wait", 0&, 0, 0)
    ´设定时间格式为 Tracks ( 预设值是 milliseconds )
    lRet = mciSendString("set cd time format tmsf", 0&, 0, 0)
    ´从头开始播放
    lRet = mciSendString("play cd", 0&, 0, 0)
    ´您也可以指定要从第几首歌 (Track) 开始播放,例如以下指定从第 3 首歌开始播放
    ´nCurrentTrack = 3
    lRet = mciSendString("play cd from" & Str(nCurrentTrack), 0&, 0, 0)
    End Sub´ 记得在播放完毕时要关闭装置
    Sub cmdStop_Click()
    Dim lRet As Long
    ´停止播放
    lRet = mciSendString("stop cd wait", 0&, 0, 0)
    DoEvents ´给 Windows一点时间去处理其他事件
    ´关闭装置
    lRet = mciSendString("close cd", 0&, 0, 0)
    End Sub
      

  3.   

    这个放cd 音乐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
    Private Sub Command2_Click()
    Dim lRet As Long
    lRet = mciSendString("stop cd wait", 0&, 0, 0)
    lRet = mciSendString("close cd", 0&, 0, 0)
    End SubPrivate Sub Command1_Click()
    Dim lRet As Long
    Dim nCurrentTrack As Integer
    lRet = mciSendString("open cdaudio alias cd wait", 0&, 0, 0)
    lRet = mciSendString("set cd time format tmsf", 0&, 0, 0)
    lRet = mciSendString("play cd", 0&, 0, 0)
    lRet = mciSendString("play cd from" & Str(nCurrentTrack), 0&, 0, 0)
    End Sub
      

  4.   

    哈哈 哥们
    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
    Private Sub Command1_Click()
        If Command1.Caption = "打开" Then
            Command1.Caption = "关闭"
            retvalue = mciSendString("set CDAudio door open", returnstring, 127, 0)
        Else
            retvalue = mciSendString("set CDAudio door closed", returnstring, 127, 0)
            Command1.Caption = "打开"
        End If
    End Sub