Welcome

首页 / 软件开发 / .NET编程技术 / .NET Compact Framework下的进程间通信之Windows Message

.NET Compact Framework下的进程间通信之Windows Message2011-08-29 博客园 Jake Lin在Wince和Windows Moblie 下的进程间通信可以由以下几种技术实现。

1. Windows Message

2. Point-to-Point Message Queues

3. MSMQ

下面使用讲述.NET Compact Framework下使用Windows Message进行进程间的 通信。

引用库

在CF.net下进行Windows Message的开发需要引用Microsoft.WindowsCE.Forms ,该DLL一般存放于C:Program FilesMicrosoft.NETSDKCompactFrameworkv2.0 WindowsCEMicrosoft.WindowsCE.Forms.dll

发送消息

using Microsoft.WindowsCE.Forms;

public partial class MsgForm : Form
{
[DllImport("coredll.dll", EntryPoint = "RegisterWindowMessage", SetLastError = true)]
private static extern uint RegisterWindowMessage(string lpString);
private uint msgUid = RegisterWindowMessage ("MESSAGE_UID");

public static int MSG_BROADCAST = 0xFFFF;

private void SendMessage(object sender)
{
Message msg = Message.Create((IntPtr) MSG_BROADCAST, (int)msgUid , IntPtr.Zero, IntPtr.Zero);
MessageWindow.SendMessage(ref msg);
}

}