MarkJ
MarkJ

Reputation: 30398

Caption in Windows taskbar right-click menu

How can I change at runtime the caption in the right-click context menu for the taskbar button for my program? I mean the text circled in red here.

enter image description here

The caption appears to be taken from the assembly title. I need to alter the caption dynamically at runtime from code. I have one EXE which the users "see" as a number of different apps - it reads data files at runtime and then customizes its appearance massively, including the window caption. I need to also customize the caption in this right-click menu. There's no single caption that covers everything. I'm willing to consider P/Invoke calls to the Windows API if necessary.

This is a WinForms .Net 4.5.2 program, screenshot is Windows 7.

Upvotes: 2

Views: 2009

Answers (2)

Boazt
Boazt

Reputation: 1

Long time ago but...

You can modify it in the "Registry Editor".

  1. Open the "Registry Editor" (in windows 10, click on START > type reg and you will have it on the search results).
  2. Click on the "Edit" menu > "Find". A dialog box will be opened.
  3. Type the name of the executable file of your program (e.g. "MyAppName.exe") > "Find Next".
  4. Now you should see property which name ends with "FriendlyAppName" and the value is the current caption name. Right click on it and then click on "Modify".
  5. Type your desired caption name in the "Value" textbox. > OK.
  6. If you have several copies of this app in your PC then go over all of them using the "Edit > Find Next" menu item and modify them all.

Be careful not to modify any other values in the Registry Editor, it may harm your PC well being.

Upvotes: 0

Vikhram
Vikhram

Reputation: 4394

I have a solution for you, but not sure it will work for you

I will make some assumptions to drive home my solution

  1. It is a winforms project built using visual studio
  2. You haven't modified your original Program.cs file
  3. All your assembly attributes are in AssembyInfo.cs

Program.cs typically looks like this

using System;
using System.Windows.Forms;

static class Program {
    [STAThread]
    static void Main() {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
}

One way to deal with it is to build your app as a Class Library sans the Program.cs, let's call it App.dll. Then merge your code from Program.cs and AssemblyInfo.cs (only relevant portions) into a single file and let's call it App.cs. You should auto-generate App.cs either with a separate script or via App.cs itself Now build App.cs referencing App.dll generating App.exe. This App.exe should work exactly like your current executable.

Once all this is established, you can already see where we are going with this.

Now, when your App.exe start's up and reads the config to make changes, you should auto-generate App.cs with a different AssemblyTitle like below

[assembly: AssemblyTitle("MyAssembly")]

and generate App-Flavor1.exe, and spawn that process and exit out of App.exe

Upvotes: 2

Related Questions