|
@@ -45,6 +45,57 @@ namespace WinBox
|
|
|
// RunBat("C:\\Lingjiao\\winBoxNode\\start.bat");
|
|
|
}
|
|
|
|
|
|
+ private void Form1_Activated(object sender, System.EventArgs e)
|
|
|
+ {
|
|
|
+ // Label1.Text = "x: " + x + " y: " + y;
|
|
|
+ // Label2.Text = "Number of forms currently open: " + count;
|
|
|
+
|
|
|
+ string tcpPort = "9191";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (tcpPort == "" || tcpPort == null)
|
|
|
+ {
|
|
|
+ MessageBox.Show("请输入TCP端口号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Process process = new Process();
|
|
|
+ process.StartInfo = new ProcessStartInfo("netstat", "/ano");
|
|
|
+ process.StartInfo.CreateNoWindow = true;
|
|
|
+ process.StartInfo.UseShellExecute = false;
|
|
|
+ process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
|
|
+ process.StartInfo.RedirectStandardOutput = true;
|
|
|
+ process.Start();
|
|
|
+ StreamReader reader = process.StandardOutput;
|
|
|
+ while (!reader.EndOfStream)
|
|
|
+ {
|
|
|
+ string msg = reader.ReadLine().ToUpper();
|
|
|
+ if (msg.IndexOf("TCP") > 0 && msg.IndexOf(":" + tcpPort) > 0)
|
|
|
+ {
|
|
|
+ string info = msg.Trim();
|
|
|
+ MessageBox.Show("TCP:" + tcpPort + "端口被占用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("TCP:" + tcpPort + "端口没有被占用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ reader.Close();
|
|
|
+ process.Close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ MessageBox.Show("检测TCP端口:" + tcpPort + "失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void RunBat(string batPath)
|
|
|
{
|
|
|
Process pro = new Process();
|
|
@@ -59,8 +110,6 @@ namespace WinBox
|
|
|
|
|
|
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/// <summary>
|