المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : SendMessage WM_GETTEXT....Please help me.



C# Programming
04-28-2009, 12:11 AM
I am trying to get the text from a notepad ********

This is my declaration:


const int WM_GETTEXT = 0x000D;
DllImport("user32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(int _WindowHandler, int _WM_USER, StringBuilder lpstring, int len);




This is what i have for my code:

Process[] p = Process.GetProcessesByName("notepad");
foreach (Process s in p)
{
StringBuilder sb = new StringBuilder(11);
SendMessage(this.Handle.ToInt32(), WM_GETTEXT, sb, 10);
code.Text += sb.ToString();
}




Please explain why my code isn't working so I can learn. http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif