using System.Text.RegularExpressions; string anyString = Regex.Replace(strIn, "[^0-9]", "");
2013年2月17日 星期日
[C#] 移除字串中非數字的字元
2013年2月4日 星期一
[C#]偵測並關閉執行中的程式
using System.Diagnostics;
...
...
//=====不可重複開啟同一支程式(將程式碼放至於偵測是否被開啟的程式中即可)=====
Process[] proc = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);
if (proc.Length > 1)
{
//表示此程式已被開啟
MessageBox.Show("程式執行中");
}
//=====偵測執行中的外部程式並關閉=====
Process[] MyProcess = Process.GetProcessesByName("程式名稱");
if (MyProcess.Length>0)
MyProcess[0].Kill(); //關閉執行中的程式
訂閱:
意見 (Atom)