c#通过SendMessage(Win API)发送消息

来源:互联网 发布:经济学就业 知乎 编辑:程序博客网 时间:2024/04/29 09:35

PART1:

来自MSDN的问答:

问:

Before, I had used SendMessage API in VB 6.0.
Now, I want quick search a string in listbox by Sendmessage API and use C# language but I don't know how to do.
Please, help me. Thanks 

PS: Sorry, my english is very poor.

答:

You need to import the function using:

            [DllImport("user32.dll")]
            public static extern int SendMessage(
                  int hWnd,      // handle to destination window
                  uint Msg,       // message
                  long wParam,  // first message parameter
                  long lParam   // second message parameter
                  );

 

and define the message that you want to send like:

public const int <WM_YOURMESSAGE> = <yourvalue>;

 

and then call SendMessage like any other function.




PART2:

函数原型:

http://www.apicx.com/show.php?id=SendMessage


PART3:

Windows消息类型,见另一篇记录:

0 0