C# sendmessage怎么向C++编译的程序发消息
publicconstintWM_SETTEXT=0x0C;[DllImport("User32.dll",EntryPoint="SendMessage")]priva...
public const int WM_SETTEXT = 0x0C;
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(
int hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
string lParam
// int lParam // second message parameter
);
private static int HdForm = 0;//窗体句柄
private static int HdText = 0;//文本框句柄
static void Main(string[] args)
{
HdForm = FindWindow("#3270", "DMUnms");
HdText = FindWindowEx(HdForm, 0, "Edit", "");
int hwdText = SendMessage(HdText, WM_SETTEXT, 0, "你好");
Console.ReadKey();
}
//用Spy++查看句柄是正确的,为什么消息发送失败呢,我用C#做了一个简单的窗口做测试,是成功的,说明语法没有错误,那么应该是参数有错,谁能教教 展开
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(
int hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
string lParam
// int lParam // second message parameter
);
private static int HdForm = 0;//窗体句柄
private static int HdText = 0;//文本框句柄
static void Main(string[] args)
{
HdForm = FindWindow("#3270", "DMUnms");
HdText = FindWindowEx(HdForm, 0, "Edit", "");
int hwdText = SendMessage(HdText, WM_SETTEXT, 0, "你好");
Console.ReadKey();
}
//用Spy++查看句柄是正确的,为什么消息发送失败呢,我用C#做了一个简单的窗口做测试,是成功的,说明语法没有错误,那么应该是参数有错,谁能教教 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询