[WinApi] C # window text box for additional content

Declarations section:

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);

 

Function part:

MWh = FindMainWindowHandle IntPtr ( " window name " , 100 , 25 );   // main window handle 
IntPtr = HwndStatue the FindWindowEx (MWh, IntPtr.Zero, " the Edit " , null );    // text box handle 
 
IF ! (HwndStatue = IntPtr. ZERO) 
{                 
    int textlen; 
    textlen = the SendMessage (HwndStatue, WM_GETTEXTLENGTH, 0 , 0 ); 
    Byte [] BYT = new new Byte [textlen]; 
    the SendMessage ( HwndStatue, the WM_GETTEXT, textlen + . 1, byt);
    string str = Encoding.Default.GetString(byt);
}

 

Guess you like

Origin www.cnblogs.com/x00479/p/12424649.html