----程序清单:
Option Explicit
Private Declare Sub Anjan Lib
“vbio.dll" ()
Private Declare Function Inp Lib
“vbio.dll" (ByVal port &) As Integer
Private Declare Function Inpw Lib
“vbio.dll" (ByVal port &) As Long
Private Declare Sub Out Lib
“vbio.dll" (ByVal port &, ByVal byt %)
Private Declare Sub Outw Lib
“vbio.dll" (ByVal port &, ByVal wrd &)
Private Declare Function GetLptBaseAddr Lib
“vbio.dll" (ByVal lpt &) As Integer
Private Declare Function GetComBaseAddr Lib
“vbio.dll" (ByVal com &) As Integer
Public Sub SetFreq(soundHz As Integer) ' 设 置 频 率
If soundHz Then
Dim divisor As Long
divisor = 1193180 / soundHz ' 计 算 时 间 常 数
Out &H42, &HB6
'8253 -5 通 道2 设 置 为 方 式3
Out &H42, divisor Mod 256 ' 送 时 间 常 数
Out &H42, divisor 256 '
Speaker True
Else
Speaker False
End If
End Sub
Public Sub Speaker(sOn As Boolean) ' 开 关 声 音
Dim portVal As Integer
portVal = Inp( &H61)
If sOn Then
portVal = portVal Or 3
' 低 位 为 通 道2 的 门 控 信 号
Else ' 次 低 位 为 整 形 与 门 控 制 信 号
portVal = portVal And (Not 3)
End If
Out &H61, portVal
End Sub
Private Sub Form_Load()
Anjan ' 软 件 解 锁
End Sub
Private Sub SoundOff_Click()
Speaker False
End Sub
Private Sub SoundOn_Click()
SetFreq Val(TextHz)
End Sub