2

I have 2 project in my solution on Visual Studio. First project (Winforms/Application) has got a notify icon with content menu strip like this:

private void TrayMenuContext()
{
    notifyIcon1.ContextMenuStrip = new ContextMenuStrip();
    notifyIcon1.ContextMenuStrip.Items.Add("Test1", null, MenuTest1_Click);
    notifyIcon1.ContextMenuStrip.Items.Add("Test2", null, MenuTest2_Click);
    notifyIcon1.ContextMenuStrip.Items.Add("Exit", null, MenuExit_Click);
}

private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Left)
    {
        var mi = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic);
        mi?.Invoke(notifyIcon1, null);
    }
}

And the second project (Winforms/Application) has got a button like this:

private void button1_Click(object sender, EventArgs e)
{
    /*
    * How should I code here to delete the notify icon content menu strip item
    * in first application named "Test2"?
    */
}

When I click the button, I want to delete the "Test2" menu item in the first application notify icon content menu strip. But unfortunately I don't have the slightest idea about it. Moreover, I do not know if such a thing is possible. However, the extraordinary features of .Net encourage me.

Habip Oğuz
  • 921
  • 5
  • 17
  • You can use one of many IPC methods to communicate with the other app – TheGeneral Jan 13 '21 at 08:13
  • Does this answer your question? [Communication between two different applications](https://stackoverflow.com/questions/5676847/communication-between-two-different-applications) – Sinatr Jan 13 '21 at 08:14
  • @Sinatr - Absolutely you are right. But this a console application example and I did not implement it into the my application. – Habip Oğuz Jan 13 '21 at 08:16

0 Answers0