任务栏右键单击windows vista及更高版本的应用程序上下文菜单



我需要知道C#中windows vista及更高版本任务栏右键单击应用程序上下文菜单的代码。对于旧版本的windows,此代码为0x313。在vista和更高版本中,此代码表示shift+右键单击。我在任务栏的应用程序上下文菜单中找不到右键单击的代码。

您想要的是将上下文菜单与Windows窗体NotifyIcon组件关联

Windows Forms NotifyIcon组件在状态中显示一个图标任务栏的通知区域。通常,应用程序允许您右键单击该图标可向应用程序发送命令代表。通过将ContextMenu组件与NotifyIcon关联组件,您可以将此功能添加到应用程序中。

public NotifyIcon notifyIcon1 = new NotifyIcon();
public ContextMenu contextMenu1 = new ContextMenu();
public void createIconMenuStructure()
{
   // Add menu items to context menu.
   contextMenu1.MenuItems.Add("&Open Application");
   contextMenu1.MenuItems.Add("S&uspend Application");
   contextMenu1.MenuItems.Add("E&xit");
   // Set properties of NotifyIcon component.
   notifyIcon1.Visible = true;
   notifyIcon1.Icon = new System.Drawing.Icon
      (System.Environment.GetFolderPath
      (System.Environment.SpecialFolder.Personal)
      + @"Icon.ico");
   notifyIcon1.Text = "Right-click me!";
   notifyIcon1.ContextMenu = contextMenu1;
}

最新更新