Many ways. You could use static field, file mapping technology, system message... You could search related information in Microsoft web site, to choose proper way for you.Hope it could be help.
调试欢乐多
string Deliver;
public Form2(string deliveryString)
{
Deliver=deliveryString;
}应用是加上参数
以前在vb6,我用过findwindow的方法。把你的exe的主窗体的标题栏文本弄得特殊一点,例如把软件名称写全,然后第二个exe先不显示,用findwindow找到第一个exe的主窗口句柄,然后setwindowpos,让其恢复,并带到前台即可。
你的理解很正确,你的方法也可以,不过如果能通过.net的类来实现就最好,API是不得已的办法。
我试过用查找进程的方法,不知道为什么总是提示进程被锁定,无法访问其中的属性。
using System;
using System.Threading;public class MutexTest {
public static void Main () {
bool notexist;
Mutex m = new Mutex(true, "MyTest", out notexist);
if (notexist) {
Console.WriteLine("This is the first instance of the process!");
} else {
Console.WriteLine("There is already one instance of the process exist!");
}
Console.ReadLine();
}
}如果要进一步通信的话,建议可以使用.NET Remoting(需要占用一个网络端口)。