using Microsoft.VisualBasic.ApplicationServices;
static void Main(string[] args)
{
App myApp = new App();
myApp.Run(args);
}
class App : WindowsFormsApplicationBase
{
public App()
{
// 设置单例模式
this.IsSingleInstance = true;
// 设置可用于XP窗口样式
this.EnableVisualStyles = true;
// 窗口关闭时的操作
this.ShutdownStyle = ShutdownMode.AfterMainFormCloses;
}
/// <summary>
/// 重写OnCreateMainForm()函数
/// </summary>
protected override void OnCreateMainForm()
{
this.MainForm = new FormMain();
}
}
}我这里已经实现了只能运行一个实例并激活,但是不知道怎么传递参数过去。。
static void Main(string[] args)
{
App myApp = new App();
myApp.Run(args);
}
class App : WindowsFormsApplicationBase
{
public App()
{
// 设置单例模式
this.IsSingleInstance = true;
// 设置可用于XP窗口样式
this.EnableVisualStyles = true;
// 窗口关闭时的操作
this.ShutdownStyle = ShutdownMode.AfterMainFormCloses;
}
/// <summary>
/// 重写OnCreateMainForm()函数
/// </summary>
protected override void OnCreateMainForm()
{
this.MainForm = new FormMain();
}
}
}我这里已经实现了只能运行一个实例并激活,但是不知道怎么传递参数过去。。
解决方案 »
- C#实体类的批量操作问题
- 请教:线程间操作无效: 从不是创建控件“pictureBox1”的线程访问它。
- DropDownList问题
- 已经设置好字体,但是程序运行时所有字体统一为小四号字,为什么?
- 求教数据库 多表查询后的更新问题
- 在if语句内的变量,怎么在if外使用?
- 帮忙!!“未将对象引用设置到对象的实例”错误是怎么回事??
- DEV控件的一个问题,关于bandedGridView的事件的
- 在实例化sqlparameter[]数组时,出错,附上源码
- DrawString(string s, Font font, Brush brush, float x, float y); 坐标单位是像素吗
- 未处理NullReferenceException
- 请教: 将查询到的结果导到EXCEL的代码 谢谢
第二次运行这个程序的时候我想要的是把第一次那个实例激活而不是再运行这个程序
而我第二次运行的时候可能是这样调用的 test.exe TwoRun
也就是说要把这个TwoRun这个参数传递到第一个实例并且让他作出反应
比如说把这个参数弹出来什么的
数据传递这块你可以看下进程间的IPC或者管道通信,这块不太熟,你最好查一下