标签:pre winapi api send dstat text sage import 句柄
声明部分:
const int WM_GETTEXT = 0x000D; const int WM_GETTEXTLENGTH = 0x000E; [DllImport("user32.dll", EntryPoint = "SendMessageA")] public static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, Byte[] lParam); [DllImport("user32.dll", EntryPoint="SendMessageA")] public static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
函数部分:
IntPtr mwh = FindMainWindowHandle("窗口名称", 100, 25); //主窗口句柄 IntPtr HwndStatue = FindWindowEx(mwh, IntPtr.Zero, "Edit", null); //文本框句柄 if (HwndStatue != IntPtr.Zero) { int TextLen; TextLen = SendMessage(HwndStatue, WM_GETTEXTLENGTH, 0, 0); Byte[] byt = new Byte[TextLen]; SendMessage(HwndStatue, WM_GETTEXT, TextLen + 1, byt); string str = Encoding.Default.GetString(byt); }
标签:pre winapi api send dstat text sage import 句柄
原文地址:https://www.cnblogs.com/dongshenjun/p/12708144.html