Reputation: 1904
I want to change the application name that shows up in windows 7 taskbar context menu.
My applicaiton currently shows my application name. I want to change it to something like microsoft product does
My application uses Prism framework and the application name I want to show will be decided on type of module. So I want to set the application name dynamically.
Upvotes: 1
Views: 8068
Reputation: 612934
You are seeing vshost32.exe
because you are running under the debugger. That's just the name of the host process used by the debugger and you cannot change that. Well, I suppose you could but it's not what you want to do. You want to change the name used by your executable.
When you run without debugging, as your users will, the application name displayed on the taskbar app popup is determined by the assembly name specified in the Application page of the project config. So, just change that to whatever you want and there's nothing more to do.
Upvotes: 8
Reputation: 15557
With managed apps you set that property via the Windows API Code Pack Library, you can use the AppID
property that is part of the Taskbar
object, which you can find in the Microsoft.WindowsAPICodePack.Shell.Taskbar
namespace. Using that property you can set and get the application ID of a given application.
You can also set it manually (if not using the pack). Just set the name setting with it's id:
void SetAppID(HWND hWnd, int iAppID)
{
IPropertyStore *pps;
HRESULT hr = SHGetPropertyStoreForWindow(hWnd, IID_PPV_ARGS(&pps));
if (SUCCEEDED(hr))
{
PROPVARIANT pv;
if (iAppID >= 0)
{
hr = InitPropVariantFromString(c_rgszAppID[iAppID], &pv);
}
else
{
PropVariantInit(&pv);
}
if (SUCCEEDED(hr))
{
hr = pps->SetValue(PKEY_AppUserModel_ID, pv);
PropVariantClear(&pv);
}
pps->Release();
}
}
And then calling it like:
private static void SetWindowAppId(string appId)
{
Microsoft.WindowsAPICodePack.Shell.ShellNativeMethods.SetWindowAppId
(OwnerHandle, "the name you want to display here");
}
See here for a full example.
Upvotes: 1