年末总结2
之前老师说我的代码可以运行多个实例,当然这是不行的。所以跑回去看自己之前更改过的Program.cs,当然这也是从网上找到的方法。(:3 」∠)
static class Program
{
[DllImport("user32.dll")]
private static extern bool FlashWindow(IntPtr hWnd, bool bInvert);
[DllImport("user32.dll")]
private static extern bool FlashWindowEx(int pfwi);
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
bool runone;
System.Threading.Mutex run = new System.Threading.Mutex(true, "single_test", out runone);
if (runone)
{
run.ReleaseMutex();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
FrmLogin frm = new FrmLogin();
int hdc = frm.Handle.ToInt32(); // write to ...
Application.Run(frm);//启动窗口
IntPtr a = new IntPtr(hdc);
}
else
{
MessageBox.Show("已经运行一个程序了。");
}
}
}
以上。
(‵▽′)ψ