源代码如下:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;
using System.Runtime.InteropServices;namespace 监控label属性进行声音循环播放
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("winmm.dll")]
public static extern bool PlaySound(string pszSound, int hmod, int fdwSound);//播放windows音乐,重载
public const int SND_FILENAME = 0x00020000;
public const int SND_ASYNC = 0x0001;
public const int SND_LOOP=0x0002;
public void NoiseOn()
{
string strPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
strPath = strPath + "\\login.wav";
PlaySound(strPath, 0, SND_LOOP | SND_FILENAME);
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Interval=5000;
timer1.Enabled=true;
timer1.Start();
} private void timer1_Tick(object sender, EventArgs e)
{
label1.Visible=true;
if (label1.Visible==true)
{
NoiseOn();
}
timer1.Enabled=false;
timer1.Stop();
}
}
}/////////////
问题:声音咋不播放呢?在另外的一台电脑上本人设计了类似的程序,只是播放一声短促的声音后,就完全没有后续的声音了。什么原因啊?请求帮助。panel容器中放置一个label加载一个图片,visible=false.点击button后运行一个timer1,等timer触发时,使用Tick事件,设置label的visible是true。然后运行一个循环播放声音的方法。但是没有声音。
解决方案 »
- 求各位大神帮忙。。。。进来看看
- 怎么检测 局域网的主机 是否开机 是否存在某个共享目录
- 请教!!
- 关于url编码
- 用.net 怎么读取邮件
- C#解析XML超长字符串的问题!高分求助!!
- 创建C#程序出现“无效的过程调用或参数”错误
- C# 中有没有为所有 数据库 Connection 定义统一的接口类? 比如 IConnection?? 在哪个包里?
- 通过GDI如何实现窗体的重绘.(Invalidated)?
- 关于读取二进制文件并转换成16进制的问题(100分)
- C# MDI父窗体调用 dll子窗体的架构如何实现
- C# Socket udp 本地通信一直正常 发布到公网后 就只有第一次数据收发正常
public static extern bool PlaySound(string szSound, IntPtr hMod, int flags);PlaySound(@".\player\01.wav", IntPtr.Zero, 0x00020000 | 0x0001);
IntPtr.Zero是什么意思啊