Mohit Vashistha
Mohit Vashistha

Reputation: 1904

Change application name shown in Win7 taskbar

I want to change the application name that shows up in windows 7 taskbar context menu.

enter image description here

My applicaiton currently shows my application name. I want to change it to something like microsoft product does

enter image description here

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

Answers (3)

Javert
Javert

Reputation: 279

In your root Window xaml, change the Title property of the Window.

Upvotes: 0

David Heffernan
David Heffernan

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.

enter image description here

enter image description here

Upvotes: 8

Erre Efe
Erre Efe

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

Related Questions