Bonjour à tous,

Je veux envoyer un message windows d'une application winforms a une autre, dont le contenu est une chaine de caractère.
Voici ce que j'ai fait, mais ca ne marche pas:

Application réceptrice:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
   protected override void WndProc(ref Message m)
        {
            if (m.Msg == 15)
            {
                if (m.WParam == (IntPtr)10)
                {
                    string recu=Marshal.PtrToStringAuto(m.LParam);
                    MessageBox.Show(recu.ToString());
                }
            }
            else
                base.WndProc(ref m);
 
        }
Application émettrice du msg:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
        [DllImport("User32.dll")]
        public static extern Int32 SendMessage(
        IntPtr hWnd, int Msg, IntPtr wParam, String lParam);
        [DllImport("user32.dll", EntryPoint = "FindWindow")]
        public static extern int FindWindow(string _ClassName, string _WindowName);
 
        private void button1_Click(object sender, EventArgs e)
        {
            int WindowHandleOfToProcess = FindWindow(null, "test2");
            try
            {
                IntPtr handle = new IntPtr(WindowHandleOfToProcess);
    Int32 retour = SendMessage(handle, 15, (IntPtr)10, "test");
                MessageBox.Show(retour .ToString());
            }
            catch (Exception ex)
            { MessageBox.Show(ex.ToString()); }
        }
Pouvez vous m'aider??
Je vous remercie par avance.