C#播放音乐,调用程序

一:C# 播放音乐

 string sound = Application.StartupPath + "/sound/msg.wav"; //Application.StartupPath:程序exe所在的位置,也可以直接写一个音乐的路径
 SoundPlayer player = new SoundPlayer(sound);
 player.Load(); //把声音加载到内存
 //player.PlayLooping();//播放
 player.Play();

二:C# 调用exe

一个程序的注销为例子:点击注销之后先找到程序打开,再关闭该程序

 if(process==null)
  {
     string path = Application.StartupPath;//这个path就是你要调用的exe程序的绝对路径
     process = new System.Diagnostics.Process();//创建一个新进程
     process.StartInfo.FileName = Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;//获取自身exe或dll的文件名
     process.StartInfo.WorkingDirectory = path;
     process.Start();
  }
     this.Close();

三:程序显示时钟

在一个Time控件里面写 代码,Time的时间间隔设置为1000ms

   private void StateTime_Tick(object sender, EventArgs e)
        {
            //显示状态栏
            StateLaber.Text = "灵心家装预算软件      " + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss");
        }

四:设置该自定义控件的透明度

        public UserControl1()
        {
            InitializeComponent();
            //设置Style支持透明背景色
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            this.BackColor = Color.FromArgb(100, 200, 200, 200);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.DrawString("", new Font("Tahoma", 8.25f), Brushes.Red, new PointF(20, 20));
        }

 

posted @ 2014-12-09 21:57  从小学吐槽  阅读(412)  评论(0编辑  收藏  举报