How to invalidate MUICache?

时间:2015-09-14 16:14:14

标签: c# windows registry

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

1 个答案:

答案 0 :(得分:0)

您可以使用以下方法删除包含应用程序可执行文件路径的MuiCache密钥中的值。

MuiCache删除该值后,通过Windows Open with对话框浏览到您的应用程序,会将您的可执行文件路径重新添加到MuiCache,并附上您的更新标题。< / p>

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);
        }
    }
}

或者,如果您想以编程方式直接更新标题,而不是DeleteValue(exePath),请致电:

muiCacheKey.SetValue(exePath, yourNewTitle);

(1)从this answer到问题How can I get the application's path in a .NET console application?