首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c# 窗体背景音乐重复循环播放解决办法

2012-05-27 
c#窗体背景音乐重复循环播放我在主窗体中加了一个背景音乐,我想让这首背景音乐在我所有窗体里都能循环播放

c# 窗体背景音乐重复循环播放
我在主窗体中加了一个背景音乐,我想让这首背景音乐在我所有窗体里都能循环播放,该怎样弄?

[解决办法]

C# code
using System.Runtime.InteropServices;public static uint SND_ASYNC = 0x0001;  // play asynchronously public static uint SND_FILENAME = 0x00020000; // name is file name[DllImport("winmm.dll")]public static extern uint mciSendString(string lpstrCommand,     string lpstrReturnString, uint uReturnLength, uint hWndCallback);private void button1_Click(object sender, EventArgs e){    mciSendString(@"close temp_alias", null, 0, 0);    mciSendString(@"open ""E:\音乐\周杰伦-东风破.mp3"" alias temp_alias",        null, 0, 0);    mciSendString("play temp_alias repeat", null, 0, 0);} 

热点排行