关闭hp打印机 cd
大家好,
这是用于打开和关闭CD TRAY的简单方法。
请发表评论!
'add this lines of code in the declaration section of a standard module.
'---------------
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
(ByVal lpszCommand As String, ByVal lpszReturnString As String, _
ByVal cchReturnLength As Long, ByVal hwndCallback As Long) As Long
'--------------
'Now in the module also declare this
'-----------------------------------
Sub opencd()
Call mciSendString("set CDAudio door open", 0, 0, 0)
End Sub
Sub closecd()
Call mciSendString("set CDAudio door closed", 0, 0, 0)
End Sub
'-----------------------------------
'Now add two command buttons to the form ( its obvious what i have taken below)
'-----------------------------------
Private Sub Command1_Click()
Call Module1.opencd
End Sub
Private Sub Command2_Click()
Call Module1.closecd
End Sub
'----------------------------------
问候
>> ALI <<
翻译自: https://bytes.com/topic/visual-basic/insights/774983-opening-closing-cd-tray
关闭hp打印机 cd
本文提供了一个简单的VBA代码示例,用于控制HP打印机的CD托盘开闭。通过调用winmm.dll库中的mciSendString函数,可以实现CD托盘的开启和关闭操作。文中详细介绍了如何在标准模块中添加代码,并通过两个命令按钮在界面上实现CD托盘的控制。

被折叠的 条评论
为什么被折叠?



