Private Declare Function APIBeep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long注意: THIS ONLY WORKS IN NT/2000/XP. IN 95/98/ME, the freqeuncy and duration parameters are ignored.
'打开MIDI输出设备 Public Declare Function midiOutOpen Lib "winmm.dll" Alias "midiOutOpen" (lphMidiOut As Long, ByVal uDeviceID As Long, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long '关闭MIDI输出设备 Public Declare Function midiOutClose Lib "winmm.dll" Alias "midiOutClose" (ByVal hMidiOut As Long) As Long '向MIDI输出设备发送短消息 Public Declare Function midiOutShortMsg Lib "winmm.dll" Alias "midiOutShortMsg" (ByVal hMidiOut As Long, ByVal dwMsg As Long) As Long
98下这样: Public Sub SetFreq(hertz As Integer) If hertz Then Dim divisor As Long divisor = 1193180 / hertz
Outport &H43, &HB6
Outport &H42, divisor Mod 256 Outport &H42, divisor \ 256
Speaker True Else Speaker False End If End SubPublic Sub Speaker(bOn As Boolean) Dim portVal As Integer
portVal = Inport(&H61) If bOn Then portVal = portVal Or 3 portVal = &H2F Else portVal = portVal And (Not 3) End If Outport &H61, portVal End Sub
bdxzq(思考) : 我用VC做了一个Dll.如下: #include <conio.h>int _stdcall outport(unsigned short a, int b) { return _outp(a, b); }int _stdcall inport(unsigned short a) { return _inp(a); }但是在VB种调用会出错!你的那些函数是那里来的。是下载的ntport.dll吗?
http://www.easthot.net
你看看是不是你要的?
THIS ONLY WORKS IN NT/2000/XP. IN 95/98/ME, the freqeuncy and duration parameters are ignored.
Beep可以在2000以上的系统正常用,没问题,我都试了。
手头没有95,98了,看到人家用循环让Beep运行N遍,不知是否针对此问题的。
例如: midiOutShortMsg(hMidiOut, (&H90 + (60 * 256) + &H7F0000))
就是发出中音C,也就是do。
例如: midiOutShortMsg(hMidiOut, (&H90 + (60 * 256) + &H7F0000))
就是发出中音C,也就是do。
Public Declare Function midiOutOpen Lib "winmm.dll" Alias "midiOutOpen" (lphMidiOut As Long, ByVal uDeviceID As Long, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long '关闭MIDI输出设备
Public Declare Function midiOutClose Lib "winmm.dll" Alias "midiOutClose" (ByVal hMidiOut As Long) As Long '向MIDI输出设备发送短消息
Public Declare Function midiOutShortMsg Lib "winmm.dll" Alias "midiOutShortMsg" (ByVal hMidiOut As Long, ByVal dwMsg As Long) As Long
Public Sub SetFreq(hertz As Integer)
If hertz Then
Dim divisor As Long
divisor = 1193180 / hertz
Outport &H43, &HB6
Outport &H42, divisor Mod 256
Outport &H42, divisor \ 256
Speaker True
Else
Speaker False
End If
End SubPublic Sub Speaker(bOn As Boolean)
Dim portVal As Integer
portVal = Inport(&H61)
If bOn Then
portVal = portVal Or 3
portVal = &H2F
Else
portVal = portVal And (Not 3)
End If
Outport &H61, portVal
End Sub
这两个函数好像就是那个范例带的第三方DLL的函数。
#include <conio.h>int _stdcall outport(unsigned short a, int b)
{
return _outp(a, b);
}int _stdcall inport(unsigned short a)
{
return _inp(a);
}但是在VB种调用会出错!你的那些函数是那里来的。是下载的ntport.dll吗?