• 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");

             

  • 相关阅读:
    vim 源码分析
    Crontab无法自动执行,直接运行脚本却能执行
    chromium源代码下载(Win7x64+VS2013sp2, 39.0.2132.2)
    linux 环境变量设置方法总结(PATH/LD_LIBRARY_PATH)
    Linux 的源码安装工具 CheckInstall
    两个开源项目要搞定
    FreeRADIUS + MySQL 安装配置笔记
    Linux指令详解useradd groupadd passwd chpasswd chage 密码修改
    Github上的几个C++开源项目
    linux 中解析命令行参数(getopt_long用法)
  • 原文地址:https://www.cnblogs.com/cuishao1985/p/1343343.html
Copyright © 2020-2023  润新知