积极答复者
怎样在入口函数调用已实例化的类的方法

问题
-
namespace WinRCC2{
static class Program{/// <summary>/// 应用程序的主入口点。/// </summary>[STAThread]
static void Main(string[] args){bool runone;System.Threading.Mutex run = new System.Threading.Mutex(true, "WinRCC2", out runone);if (args.Length < 1 || args == null){if (runone){run.ReleaseMutex();Application.EnableVisualStyles();//Application.OpenForms.;Application.SetCompatibleTextRenderingDefault(false);Application.Run(new RCCMain());}else{MessageBox.Show("中心系统已运行!");}}else{if (runone==false){if (args.Length >= 1 & args != null){if (args[0] != ""){RCCMain.pCurrentRCCMain.CustCallOut(args[0]);}}}}}}}
在我调用 RCCMain.pCurrentRCCMain.CustCallOut(args[0]); 时不能获取当前的已运行的 RCCMain()的方法,请问有什么方法解决,谢谢!
答案
-
通过调用SendMessage 传递参数 这属于跨进程通信了
Raymond Tang (Microsoft C# MVP)
Denn Ich Gehoer nur mir
.NET交流群71840452
微软中文论坛同城社区成都QQ群:74268428
My Chinese Blog
Chengdu,Sichuan Province,China- 已标记为答案 ThankfulHeartModerator 2010年11月12日 6:23
全部回复
-
namespace WinRCC2{
static class Program{/// <summary>/// 应用程序的主入口点。/// </summary>[STAThread]
static void Main(string[] args){bool runone;System.Threading.Mutex run = new System.Threading.Mutex(true, "WinRCC2", out runone);if (args.Length < 1 || args == null){if (runone){run.ReleaseMutex();Application.EnableVisualStyles();//Application.OpenForms.;Application.SetCompatibleTextRenderingDefault(false);Application.Run(new RCCMain());}else{MessageBox.Show("中心系统已运行!");}}else{if (runone==false){if (args.Length >= 1 & args != null){if (args[0] != ""){RCCMain.pCurrentRCCMain.CustCallOut(args[0]);}}}}}}}
我想通过cmd命令在入口函数的定义不同的参数调用本程式中的某个窗口,而当前本程式已在运行。在我调用 RCCMain.pCurrentRCCMain.CustCallOut(args[0]); 时不能获取当前的已运行的 RCCMain()的方法,请问有什么方法解决,谢谢! -
通过调用SendMessage 传递参数 这属于跨进程通信了
Raymond Tang (Microsoft C# MVP)
Denn Ich Gehoer nur mir
.NET交流群71840452
微软中文论坛同城社区成都QQ群:74268428
My Chinese Blog
Chengdu,Sichuan Province,China- 已标记为答案 ThankfulHeartModerator 2010年11月12日 6:23