⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 43.txt

📁 VB文章集(含API、窗口、数据库、多媒体、系统、文件、等等)
💻 TXT
字号:
控制光驱门的开关 
     利用MCI的方法可以方便的实现光驱门的开关。
请看下例:
>>步骤1----建立新工程,在窗体上放置一个CommandButton按钮.设置其Caption = "打开"
>>步骤2----编写如下代码:

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()
    Static bOpen As Boolean
    Dim strStr As String

    If Not bOpen Then
        Screen.MousePointer = vbHourglass
        strStr = "set CDAudio door open"
    Command1.Caption = "关闭"
    Else
        Screen.MousePointer = vbHourglass
        strStr = "set CDAudio door closed"
     Command1.Caption = "打开"
    End If

    Call mciSendString(strStr, vbNull, 127, 0)
    Screen.MousePointer = vbDefault
    DoEvents
    bOpen = Not bOpen
End Sub

>>步骤3----编译运行,点击"打开",光驱弹出;点击"关闭",光驱关上.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -