需要将彩铃文件放到 D:/ssss/aaaa.mp3目录
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace WindowsFormsApplication1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } int s; string[] names = new string[6]; private void Form1_Load(object sender, EventArgs e) { s = 0; ssss.URL = @"D:\ssss\aaaa.mp3"; ssss.Ctlcontrols.play(); names[0] = @"D:\ssss\cccc.mp3"; names[1] = @"D:\ssss\dddd.mp3"; names[3] = @"D:\ssss\aaaa.mp3"; names[2] = @"D:\ssss\c.mp3"; names[4] = @"D:\ssss\s.mp3"; names[5] = @"D:\ssss\ssss.mp3"; string ssss0 = this.GetType().Assembly.Location; // string ssss = "sssscscs"; 0开始最后一次出现的位置 int s0 = ssss0.LastIndexOf("\\"); //cccc.Text =s.ToString(); int c = ssss0.Length - s0 - 1; cccc411.Text = ssss0.Substring(ssss0.Length - c, c);//名称和扩展名 s0 = cccc411.Text.LastIndexOf("."); cccc411.Text = cccc411.Text.Substring(0, s0);//名称 } private void cccc(string s0) { ssss.URL = s0; ssss.Ctlcontrols.play(); } private void timer1_Tick(object sender, EventArgs e) { //label1.Text = h.ToString(); if (ssss410.Text != "" || ssss401.Text != "") { int h = DateTime.Now.Hour; //获取当前时间的小时部分 if (h == int.Parse(ssss410.Text) || h == int.Parse(ssss401.Text)) //获取当前时间的小时部分) { System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses(); foreach (System.Diagnostics.Process myProcess in myProcesses) { // ssss0.Text = ssss0.Text Environment.NewLine myProcess.ProcessName; if (myProcess.ProcessName == cccc411.Text)//程序名在任务管理器里的程序名不带扩展名 myProcess.Kill();//关闭该程序 } } } //--------------------------------------------------------------- if (ssss402.Text != "" || ssss405.Text != "") { int m = DateTime.Now.Minute; //获取当前时间的分钟部分 if (m == int.Parse(ssss402.Text) || m == int.Parse(ssss405.Text)) //获取当前时间的小时部分) { System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses(); foreach (System.Diagnostics.Process myProcess in myProcesses) { // ssss0.Text = ssss0.Text Environment.NewLine myProcess.ProcessName; if (myProcess.ProcessName == cccc411.Text)//程序名在任务管理器里的程序名不带扩展名 myProcess.Kill();//关闭该程序 } } } //--------------------------------------------------------------- if (this.ssss.playState.ToString() == "wmppsStopped") { cccc(names[s]); s ; if (s == 6) { s = 0; } } } private void button1_Click(object sender, EventArgs e) { timer1.Enabled = true; } }}
评论