📄 vbtips1.htm
字号:
stopped. <br>
' That is, use a 0& to provide a NULL value. </p>
<p>' wFlags% </p>
<p>' Specifies options for playing the sound using one or
more <br>
' of the following flags: <br>
' SND_SYNC: The sound is played synchronously and the
function <br>
' does not return until the sound ends. <br>
' SND_ASYNC: The sound is played asynchronously and the
function <br>
' returns immediately after beginning the sound. <br>
' SND_NODEFAULT: If the sound cannot be found, the
function returns <br>
' silently without playing the default sound. <br>
' SND_LOOP: The sound will continue to play
repeatedly until <br>
' sndPlaySound is called again with the lpszSoundName$
parameter <br>
' set to null. <br>
' You must also specify the SND_ASYNC flag to loop
sounds. <br>
' SND_NOSTOP: If a sound is currently playing, the
function will <br>
' immediately return False without playing the requested
sound. </p>
<p>' Add the following code to the appropriate routine: </p>
<p>Dim SoundName$ <br>
Dim wFlags% <br>
Dim x% </p>
<p> SoundName$ =
"c:\windows\tada.wav" ' The file to play <br>
wFlags% = SND_ASYNC Or SND_NODEFAULT <br>
x% = sndPlaySound(SoundName$,wFlags%) <br>
<a href="#top">返回</a></p>
<p><br>
<a name="怎样检查声卡的存在"></a><font size="4"><strong>怎样检查声卡的存在</strong></font><br>
'-------------------------------------------------------------------
<br>
'Author: Gordon F. MacLeod <br>
'How to detect if a sound card exists on a system. <br>
'-------------------------------------------------------------------
<br>
' Here's how to detect if a sound card exists </p>
<p>' Declare this API <br>
Declare Function auxGetNumDevs% Lib
"MMSYSTEM" () </p>
<p>' In the appropriate routine: </p>
<p>Dim i As Integer <br>
i = auxGetNumDevs() </p>
<p>If i > 0 Then ' There is at least one sound card on
the system <br>
MsgBox "A Sound Card has been
detected." </p>
<p>Else ' auxGetNumDevs returns a 0 if there is no sound
card <br>
MsgBox "There is no Sound Card on
this system." </p>
<p>End If <br>
<a href="#top">返回</a> </p>
<p><br>
<a name="如何用API及MMSYSTEM.DLL播放AVI文件"></a><font
size="4"><strong>如何用API及MMSYSTEM.DLL播放AVI文件</strong></font><br>
<br>
'Author: Gordon F. MacLeod <br>
'How to play an .AVI file using API and the
MMSYSTEM.DLL.. <br>
'-------------------------------------------------------------------
<br>
' Here's how to play an .AVI file via API </p>
<p>' Declare this API: </p>
<p>Declare Function mciSendString& Lib
"MMSYSTEM" (ByVal pstrCommand$, <br>
ByVal lpstrReturnStr As Any, ByVal wReturnLen%, ByVal
CallBack%) </p>
<p>'Add this code to the appropriate event: </p>
<p>Dim CmdStr$ <br>
Dim ReturnVal& </p>
<p> ' Modify path and filename as
necessary <br>
CmdStr$ = "play
G:\VFW_CINE\AK1.AVI" <br>
ReturnVal& =
mciSendString(CmdStr$, 0&, 0, 0&) </p>
<p>' To play the AVI 'fullscreen' append to CmdStr$: </p>
<p> CmdStr$ = "play
G:\VFW_CINE\AK1.AVI fullscreen" <br>
<a href="#top">返回</a></p>
<p><br>
------------------------------------------------------------------------
<br>
<a name="如何从sound"></a><font size="4"><strong>如何从"SOUND.DRV"中提取声音</strong></font><br>
'-------------------------------------------------------------------
<br>
'Author: Gordon F. MacLeod <br>
'How to extract sounds from the SOUND.DRV library.. <br>
' Here are 4 different sound effects that can called <br>
' via API's to the "SOUND.DRV" library. You can
modify <br>
' the values to create your own unique sounds. </p>
<p>' Declare these API's: </p>
<p>Declare Function OpenSound% Lib "sound.drv"
() <br>
Declare Function VoiceQueueSize% Lib
"sound.drv" (ByVal nVoice%, ByVal nByteS) <br>
Declare Function SetVoiceSound% Lib "sound.drv"
(ByVal nSource%, ByVal Freq&, <br>
ByVal nDuration%) <br>
Declare Function StartSound% Lib "sound.drv" ()
<br>
Declare Function CloseSound% Lib "sound.drv" ()
<br>
Declare Function WaitSoundState% Lib
"sound.drv" (ByVal State%) </p>
<p>' Add this routine, to be used with SirenSound1
routine </p>
<p>Sub Sound (ByVal Freq As Long, ByVal Duration As
Integer) <br>
Dim S As Integer <br>
' Shift frequency to high byte. <br>
Freq = Freq * 2 ^ 16 <br>
S = SetVoiceSound(1, Freq, Duration) <br>
S = StartSound() <br>
While (WaitSoundState(1) <> 0): Wend <br>
End Sub <br>
</p>
<p>' Here are the 4 sound routines: </p>
<p>'* Attention Sound #1 * <br>
Sub AttenSound1 () <br>
Dim Succ, S As Integer <br>
Succ = OpenSound() <br>
S = SetVoiceSound(1, 1500 * 2 ^ 16, 50) <br>
S = SetVoiceSound(1, 1000 * 2 ^ 16, 50) <br>
S = SetVoiceSound(1, 1500 * 2 ^ 16, 100) <br>
S = SetVoiceSound(1, 1000 * 2 ^ 16, 100) <br>
S = SetVoiceSound(1, 800 * 2 ^ 16, 40) </p>
<p> S = StartSound() <br>
While (WaitSoundState(1) <> 0): Wend <br>
Succ = CloseSound() </p>
<p>End Sub </p>
<p>'* Click Sound #1 * <br>
Sub ClickSound1 () <br>
Dim Succ, S As Integer <br>
Succ = OpenSound() <br>
S = SetVoiceSound(1, 200 * 2 ^ 16, 2) <br>
S = StartSound() <br>
While (WaitSoundState(1) <> 0): Wend <br>
Succ = CloseSound() </p>
<p>End Sub </p>
<p>'* Error Sound #1 * <br>
Sub ErrorSound1 () <br>
Dim Succ, S As Integer <br>
Succ = OpenSound() <br>
S = SetVoiceSound(1, 200 * 2 ^ 16, 150) <br>
S = SetVoiceSound(1, 100 * 2 ^ 16, 100) <br>
S = SetVoiceSound(1, 80 * 2 ^ 16, 90) <br>
S = StartSound() <br>
While (WaitSoundState(1) <> 0): Wend <br>
Succ = CloseSound() <br>
End Sub </p>
<p>'* SirenSound #1 * <br>
Sub SirenSound1 () <br>
Dim Succ As Integer <br>
Dim J As Long <br>
Succ = OpenSound() <br>
For J = 440 To 1000 Step 5 <br>
Call Sound(J, J / 100) <br>
Next J <br>
For J = 1000 To 440 Step -5 <br>
Call Sound(J, J / 100) <br>
Next J <br>
Succ = CloseSound() </p>
<p>End Sub <br>
<a href="#top">返回</a></p>
<p><br>
<a name="如何用API播放CD"></a><font size="4"><strong>如何用API播放CD</strong></font><br>
<br>
'Author: Gordon F. MacLeod <br>
' How to play a CD Audio disc via API </p>
<p>' Declare the following API <br>
Declare Function mciSendString& Lib
"MMSYSTEM" (ByVal lpstrCommand$, <br>
ByVal lpstrReturnStr As Any, ByVal wReturnLen%, ByVal
hCallBack%) </p>
<p>'Add the code below to appropriate routines </p>
<p>Sub cmdPlay_Click () <br>
Dim lRet As Long <br>
Dim nCurrentTrack As Integer </p>
<p>'Open the device <br>
lRet = mciSendString("open cdaudio alias cd
wait", 0&, 0, 0) </p>
<p>'Set the time format to Tracks (default is
milliseconds) <br>
lRet = mciSendString("set cd time format tmsf",
0&, 0, 0) </p>
<p>'Then to play from the beginning <br>
lRet = mciSendString("play cd", 0&, 0, 0) </p>
<p>'Or to play from a specific track, say track 4 <br>
nCurrentTrack = 4 <br>
lRet = mciSendString("play cd from" &
Str(nCurrentTrack), 0&, 0, 0) </p>
<p>End Sub <br>
</p>
<p>' Remember to Close the device when ending playback </p>
<p>Sub cmdStop_Click () <br>
Dim lRet As Long </p>
<p>'Stop the playback <br>
lRet = mciSendString("stop cd wait", 0&, 0,
0) </p>
<p>DoEvents 'Let Windows process the event </p>
<p>'Close the device <br>
lRet = mciSendString("close cd", 0&, 0, 0) </p>
<p>End Sub <br>
<a href="#top">返回</a></p>
</td>
</tr>
</table>
</center></div>
<hr>
<div align="center"><center>
<table border="0" width="88%">
<tr>
<td width="80%"><p align="left"><a
href="vbtips.htm#Return">[1]</a> [2] <a
href="vbtips2.htm">[3]</a> <a href="vbtips3.htm">[4]</a> <a
href="vbtips4.htm">[5]</a> <a href="vbtips5.htm">[6]</a> <a
href="vbtips7.htm">[7]</a> <a href="#home">[8]</a> <a
href="vbtips9.htm">[9]</a> <a href="vbtips10.htm">[10]</a></p>
</td>
<td><p align="right"><font size="2">第二页(共十页)</font></p>
</td>
</tr>
</table>
</center></div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -