VB对光驱的控制

来源:百度文库 编辑:神马文学网 时间:2024/04/27 16:50:05
关于VB光驱的控制
Private Declare Function mciExecute Lib "winmm.dll" Alias "mciExecute" (ByVal lpstrCommand As String) As Long
以上是声明一句API,VB不能直接调用API函数。所以先声明一下,以下是详解
private :私有的一个窗体模块级变量。
declare :外部的一个过程
function:有返回值的一个函数。无返回值的用sub
mciExecute :函数名字
Lib :在,库。
"winmm.dll" 是动态库的名字
Alias 别名,因为有的API函数和VB内置函数是一个样子的。所以加个别名
(ByVal lpstrCommand As String) :一个参数,在C中是一个字符指针,在VB中是一个子符串
As Long:说明返回值是长整形。
开光驱的命令是 mciExecute "set cdaudio door open"
关光驱的命令是 mciExecute "set cdaudio door closed"