简体   繁体   中英

How to invalidate MUICache?

I've modified my C# application name by right clicking on project -> Application -> Assembly information -> Title.

If the application is already installed then it is not updating the name because it is pulling the application name from MUICache which is not getting refreshed.

I'm trying to find out a way where I can make MUICache get invalidated programmatically so that it will update the application name appropriately.

Thanks

You can use the following method to delete the value in the MuiCache key that contains the path to your application executable.

After that value has been deleted from MuiCache , browsing to your application via the Windows Open with dialog will re-add the path to your executable to MuiCache with your updated title.

using Microsoft.Win32;
using System.Linq;
using System.Reflection;

const string MuiCacheKeyPath =
    @"Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache";

static void DeleteExecutablePathFromMuiCache()
{
    string exePath = Assembly.GetExecutingAssembly().Location; // (1)

    using (RegistryKey muiCacheKey = Registry.CurrentUser
        .OpenSubKey(MuiCacheKeyPath, writable: true))
    {
        if (muiCacheKey.GetValueNames().Contains(exePath))
        {
            muiCacheKey.DeleteValue(exePath);
        }
    }
}

Alternatively, if you want to programmatically update the title directly, instead of DeleteValue(exePath) , call:

muiCacheKey.SetValue(exePath, yourNewTitle);

(1) From this answer to the question How can I get the application's path in a .NET console application? .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM