启动XAMPP控制面板的MySQL和Apache

时间:2018-06-09 12:23:46

标签: c#

是否可以通过单击按钮使用C#启动XAMPP控制面板的MySQL和Apache?

提前感谢..

1 个答案:

答案 0 :(得分:0)

我认为这是一个简单的方法:

  • 将Appache和MySQL设置为以XAMPP Panel(XMPP Panel -> Options -> Autostart of modules
  • 开头
  • 制作WinForm应用程序
  • 在其上添加一个按钮
  • 向按钮添加点击事件(称为startMySqlAndAppache_Clicklike this
  • 双击按钮
  • 将打开的文件更改为与Form1.cs
  • 相同

<强> Form1.cs的

using System;
using System.Diagnostics;
using System.Windows.Forms;

namespace XAMPP_starter
{
    public partial class Form1 : Form
    {
        private string _xamppPanelPath;

        public Form1()
        {
            // Your absolute path to the XAMPP panel (for eg.:)
            _xamppPanelPath = @"C:\xampp\xampp-control.exe";

            InitializeComponent();
        }

        private void startMySqlAndAppache_Click(object sender, EventArgs e)
        {
            // Start the XAMPP Panel with this code
            Process.Start(_xamppPanelPath);
        }
    }
}