zoukankan      html  css  js  c++  java
  • C#.NET Sonnd Class

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Media;
    using System.Runtime.InteropServices;
    using System.Text;

    namespace PAL_MES.BRLibrary
    {
        class CPlaySound
        {
            /// <summary>
            /// Invoke Window API for playing sound file
            /// </summary>
            /// <param name="lpszSoundName">FileName with its full path</param>
            /// <param name="fSound">Flag</param>
            /// <returns></returns>
            [DllImport("winmm.dll")]
            protected static extern bool sndPlaySound(string lpszSoundName, fuSound fSound);
            /// <summary>
            /// Enum Sound properties
            /// </summary>
            protected enum fuSound
            {
                SND_SYNC = 0,
                SND_ASYNC = 1,
                SND_NODEFAULT = 2,
                SND_MEMORY = 4,
                SND_LOOP = 8
            };
            /// <summary>
            /// Invoke System API function to play sound file
            /// </summary>
            /// <param name="strFileWithFullPath">FileName and its absolute path</param>

            public void PlaySound(string strFileWithFullPath)
            {
                try
                {
                    bool bRtn = sndPlaySound(strFileWithFullPath, fuSound.SND_NODEFAULT);
                }
                catch
                {
                }
            }
        }
    }

    客户端应用:CPlaySound Sound = new CPlaySound();

                     Sound.PlaySound(Application.StartupPath + @"\OO.wav");

             

  • 相关阅读:
    [Android] 布局优化技巧
    [Android] 仿照 Last App Switcher 写的小程序
    [Java] 用 Comparator 实现排序
    [Android] Service服务详解以及如何使service服务不被杀死
    [MarkDown] markdown语法小结
    [Android] TextView长按复制实现方法小结(转载)
    [Android] 关于系统工具栏和全屏沉浸模式
    [Android] 锁定屏幕
    [Android] 针对生成的图片文件在系统Gallery不显示的处理
    [Android] TableLayout
  • 原文地址:https://www.cnblogs.com/cuishao1985/p/1343343.html
Copyright © 2011-2022 走看看