在C#中如何调用SendMessage函数?

xghost 2003-10-06 08:44:27
在C#中如何调用SendMessage函数?
是调用.Net标准类库中的成员函数还是调用Win32 Api?具体如何调用?
...全文
142 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
cmsoft 2003-10-06
  • 打赏
  • 举报
回复
转:

[DllImport("USER32.DLL", CharSet=CharSet.Auto, SetLastError=true)]
public static extern bool SendMessage(
IntPtr hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
[MarshalAs(UnmanagedType.LPTStr)]StringBuilder lParam // second message parameter
);
const int WM_GETTEXT =0x000D;

StringBuilder ret = new StringBuilder(256);
if(SendMessage((IntPtr)this.Handle,WM_GETTEXT, 100, ret))
MessageBox.Show(ret.ToString());

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧