⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vbtips1.htm

📁 所有我收藏的VB技巧
💻 HTM
📖 第 1 页 / 共 2 页
字号:
        stopped. <br>
        ' That is, use a 0&amp; 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:&nbsp; 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>&nbsp;&nbsp; SoundName$ =
        &quot;c:\windows\tada.wav&quot; ' The file to play <br>
        &nbsp;&nbsp; wFlags% = SND_ASYNC Or SND_NODEFAULT <br>
        &nbsp;&nbsp; x% = sndPlaySound(SoundName$,wFlags%) <br>
        &nbsp; <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>
        &nbsp;&nbsp;&nbsp; Declare Function auxGetNumDevs% Lib
        &quot;MMSYSTEM&quot; () </p>
        <p>' In the appropriate routine: </p>
        <p>Dim i As Integer <br>
        &nbsp;&nbsp;&nbsp; i = auxGetNumDevs() </p>
        <p>If i &gt; 0 Then ' There is at least one sound card on
        the system <br>
        &nbsp;&nbsp;&nbsp; MsgBox &quot;A Sound Card has been
        detected.&quot; </p>
        <p>Else ' auxGetNumDevs returns a 0 if there is no sound
        card <br>
        &nbsp;&nbsp;&nbsp; MsgBox &quot;There is no Sound Card on
        this system.&quot; </p>
        <p>End If <br>
        <a href="#top">返回</a>&nbsp; </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&amp; Lib
        &quot;MMSYSTEM&quot; (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&amp; </p>
        <p>&nbsp;&nbsp;&nbsp; ' Modify path and filename as
        necessary <br>
        &nbsp;&nbsp;&nbsp; CmdStr$ = &quot;play
        G:\VFW_CINE\AK1.AVI&quot; <br>
        &nbsp;&nbsp;&nbsp; ReturnVal&amp; =
        mciSendString(CmdStr$, 0&amp;, 0, 0&amp;) </p>
        <p>' To play the AVI 'fullscreen' append to CmdStr$: </p>
        <p>&nbsp;&nbsp;&nbsp; CmdStr$ = &quot;play
        G:\VFW_CINE\AK1.AVI fullscreen&quot; <br>
        <a href="#top">返回</a></p>
        <p><br>
        ------------------------------------------------------------------------
        <br>
        <a name="如何从sound"></a><font size="4"><strong>如何从&quot;SOUND.DRV&quot;中提取声音</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 &quot;SOUND.DRV&quot; 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 &quot;sound.drv&quot;
        () <br>
        Declare Function VoiceQueueSize% Lib
        &quot;sound.drv&quot; (ByVal nVoice%, ByVal nByteS) <br>
        Declare Function SetVoiceSound% Lib &quot;sound.drv&quot;
        (ByVal nSource%, ByVal Freq&amp;, <br>
        ByVal nDuration%) <br>
        Declare Function StartSound% Lib &quot;sound.drv&quot; ()
        <br>
        Declare Function CloseSound% Lib &quot;sound.drv&quot; ()
        <br>
        Declare Function WaitSoundState% Lib
        &quot;sound.drv&quot; (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>
        &nbsp;&nbsp; Freq = Freq * 2 ^ 16 <br>
        &nbsp;&nbsp; S = SetVoiceSound(1, Freq, Duration) <br>
        &nbsp;&nbsp; S = StartSound() <br>
        &nbsp;&nbsp; While (WaitSoundState(1) &lt;&gt; 0): Wend <br>
        End Sub <br>
        &nbsp; </p>
        <p>' Here are the 4 sound routines: </p>
        <p>'* Attention Sound #1 * <br>
        Sub AttenSound1 () <br>
        Dim Succ, S As Integer <br>
        &nbsp;&nbsp; Succ = OpenSound() <br>
        &nbsp;&nbsp; S = SetVoiceSound(1, 1500 * 2 ^ 16, 50) <br>
        &nbsp;&nbsp; S = SetVoiceSound(1, 1000 * 2 ^ 16, 50) <br>
        &nbsp;&nbsp; S = SetVoiceSound(1, 1500 * 2 ^ 16, 100) <br>
        &nbsp;&nbsp; S = SetVoiceSound(1, 1000 * 2 ^ 16, 100) <br>
        &nbsp;&nbsp; S = SetVoiceSound(1, 800 * 2 ^ 16, 40) </p>
        <p>&nbsp;&nbsp; S = StartSound() <br>
        &nbsp;&nbsp; While (WaitSoundState(1) &lt;&gt; 0): Wend <br>
        &nbsp;&nbsp; Succ = CloseSound() </p>
        <p>End Sub </p>
        <p>'* Click Sound #1 * <br>
        Sub ClickSound1 () <br>
        Dim Succ, S As Integer <br>
        &nbsp;&nbsp; Succ = OpenSound() <br>
        &nbsp;&nbsp; S = SetVoiceSound(1, 200 * 2 ^ 16, 2) <br>
        &nbsp;&nbsp; S = StartSound() <br>
        &nbsp;&nbsp; While (WaitSoundState(1) &lt;&gt; 0): Wend <br>
        &nbsp;&nbsp; Succ = CloseSound() </p>
        <p>End Sub </p>
        <p>'* Error Sound #1 * <br>
        Sub ErrorSound1 () <br>
        Dim Succ, S As Integer <br>
        &nbsp;&nbsp; Succ = OpenSound() <br>
        &nbsp;&nbsp; S = SetVoiceSound(1, 200 * 2 ^ 16, 150) <br>
        &nbsp;&nbsp; S = SetVoiceSound(1, 100 * 2 ^ 16, 100) <br>
        &nbsp;&nbsp; S = SetVoiceSound(1, 80 * 2 ^ 16, 90) <br>
        &nbsp;&nbsp; S = StartSound() <br>
        &nbsp;&nbsp; While (WaitSoundState(1) &lt;&gt; 0): Wend <br>
        &nbsp;&nbsp; Succ = CloseSound() <br>
        End Sub </p>
        <p>'* SirenSound #1 * <br>
        Sub SirenSound1 () <br>
        Dim Succ As Integer <br>
        Dim J As Long <br>
        &nbsp;&nbsp; Succ = OpenSound() <br>
        &nbsp;&nbsp; For J = 440 To 1000 Step 5 <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Call Sound(J, J / 100) <br>
        &nbsp;&nbsp; Next J <br>
        &nbsp;&nbsp; For J = 1000 To 440 Step -5 <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Call Sound(J, J / 100) <br>
        &nbsp;&nbsp; Next J <br>
        &nbsp;&nbsp; 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&amp; Lib
        &quot;MMSYSTEM&quot; (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(&quot;open cdaudio alias cd
        wait&quot;, 0&amp;, 0, 0) </p>
        <p>'Set the time format to Tracks (default is
        milliseconds) <br>
        lRet = mciSendString(&quot;set cd time format tmsf&quot;,
        0&amp;, 0, 0) </p>
        <p>'Then to play from the beginning <br>
        lRet = mciSendString(&quot;play cd&quot;, 0&amp;, 0, 0) </p>
        <p>'Or to play from a specific track, say track 4 <br>
        nCurrentTrack = 4 <br>
        lRet = mciSendString(&quot;play cd from&quot; &amp;
        Str(nCurrentTrack), 0&amp;, 0, 0) </p>
        <p>End Sub <br>
        &nbsp; </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(&quot;stop cd wait&quot;, 0&amp;, 0,
        0) </p>
        <p>DoEvents&nbsp; 'Let Windows process the event </p>
        <p>'Close the device <br>
        lRet = mciSendString(&quot;close cd&quot;, 0&amp;, 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 + -