当使用winform启动WPF应用时,传参比较简单,直接使用进程之间传递参数,若winform向已启动的WPF中传参数,则使用消息处理
winform程序,本例使用控制台
实体类
namespace ConsoleApplication1
{
[StructLayout(LayoutKind.Sequential)]
public struct Entity
{
public IntPtr dwData;
public int cbData;
[MarshalAs(UnmanagedType.LPStr)]
public string lpData;
}
}
</pre><pre name="code" class="csharp">
发送端(控制台程序)
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string ch = "";
while (ch.ToLower() != "q")
{
if (!SendMessage("MainWindow",ch))
{
Console.Writ