然后在你声明bootstrap上面声明
var client=new ClientHandler()
...其它代码
pipline.AddLast(client)
这样在接收到消息之后,你直接访问client.Message里面就有你要的消息并毁
这种写法你看一下const int WM_COPYDATA = 0x004A
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(
int hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
ref COPYDATASTRUCT lParam /耐老森/ second message parameter
)
[DllImport("User32.dll", EntryPoint = "FindWindow")]
private static extern int FindWindow(string lpClassName, string
lpWindowName)
private void button1_Click(object sender, EventArgs e)
{
int WINDOW_HANDLER = FindWindow(null, "指南针优化软件")
if (WINDOW_HANDLER == 0)
{
Process p = new Process()
p.StartInfo.FileName = Application.StartupPath + "\\..\\ZNZ.exe"
p.Start()
Application.Exit()
}
else
{
byte[] sarr = System.Text.Encoding.Default.GetBytes(this.textBox1.Text)
int len = sarr.Length
COPYDATASTRUCT cds
cds.dwData = (IntPtr)100
cds.lpData = this.textBox1.Text
cds.cbData = len + 1
SendMessage(WINDOW_HANDLER, WM_COPYDATA, 0, ref cds)
}
}
public struct COPYDATASTRUCT
{
public IntPtr dwData//用户定义数据
public int cbData//数据昌亩大小含带
[MarshalAs(UnmanagedType.LPStr)]
public string lpData//指向数据的指针
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)