互联网的每个变化都能让我兴奋不已
« 鲜果榜TOP10精彩博客鲜果使用技巧助你提高阅读效率 »

用VB编程实现弹光驱功能

上次我介绍了一下如何用VB实现和陌生人聊天(点击查看),现在介绍一下如何用VB编程实现弹光驱功能。我要说一句,其实我的VB水平很菜,也就是刚刚入门。如果以后有时间会继续学习的。

实现此功能的完整代码如下所示:

'添加 Command1

Option Explicit
Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
Private Sub Form_Load()
Command1.Caption = "弹 出"
End Sub

Private Sub Command1_Click()
If Command1.Caption = "弹 出" Then
mciExecute "set cdaudio door open" '弹出光驱
Command1.Caption = "关 闭"
Else
mciExecute "set cdaudio door closed" '关闭光驱
Command1.Caption = "弹 出"
End If
End Sub

你只需要把代码复制到新窗体中就可以了。

点击下载exe文件

点击下载源代码

  • quote 1.andkylee
  • 2008-4-9 19:10:38 回复该留言
  • 公司的程序中查看光盘内容时,正好也用到了这个功能。检测出光盘是否有内容,是否是有效的案卷光盘时,会弹出光驱。
    PB和VB的实现方法一样,都是适用mcicommand字符命令。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最近发表

MsnSpace Designed By Erentan.Powered By Z-Blog1.8 Spirit.鲁ICP备07502173号

Copyright©2007-2008 liuzhenyun.com .  Some Rights Reserved.