Reputation: 30398
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.
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
Reputation: 1
Long time ago but...
You can modify it in the "Registry Editor".
Be careful not to modify any other values in the Registry Editor, it may harm your PC well being.
Upvotes: 0
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
Program.cs
fileProgram.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