• 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));
            }
  • 相关阅读:
    网络基础
    Web开发几种常用工具
    win组合键概述(windows10)
    Alfred使用
    Java8之新特性--modules
    jsp九大内置对象和四大作用域
    authtype
    Myeclipse中的快捷键
    如何在Jenkins CI 里调试
    写好unit test的建议和例子
  • 原文地址:https://www.cnblogs.com/Alvin-ftd/p/4154297.html
Copyright © 2020-2023  润新知