Windows:更改与文件类型关联的应用程序的名称/图标 [英] Windows: Changing the name/icon of an application associated with a file type

查看:129
本文介绍了Windows:更改与文件类型关联的应用程序的名称/图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 Windows 中的文件类型与特定应用程序相关联,但我需要这样做,当用户打开打开方式"菜单时,列表中应用程序的名称和图标是为此自定义的文件类型(即,不仅仅是可执行文件的名称和图标).

I would like to associate a file type in Windows with a particular application, but I need to make it so when the user opens the "Open With" menu, the name and icon of the application in the list is customized for that file type (i.e., not simply the name and icon of the executable).

这是因为二进制文件是运行许多不同应用程序的通用二进制文件,具体取决于其命令行参数(类似于python.exejavaws.exe).我不希望打开方式"菜单显示Python"或Java",我希望它显示在命令行上传递的应用程序的名称和图标.

This is because the binary is a general binary that runs many different apps, depending on its command-line arguments (similar topython.exe or javaws.exe). I don't want the "Open With" menu to show "Python" or "Java", I want it to show the name and icon for the application that is being passed on the command-line.

我知道如何添加文件关联(通过创建一个 ProgIDHKEY_CLASSES_ROOT 中,并将 ProgID 名称添加到 OpenWithProgidsHKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts),但我不能找到任何方法来更改应用程序的名称或图标,因为它出现在该类型文件的打开方式"菜单中.这可能吗?

I know how to add file associations (by creating a ProgID in HKEY_CLASSES_ROOT, and adding the ProgID name to either OpenWithProgids or HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts), but I cannot find any way to change the name or icon of the application as it appears in the "Open With" menu for files of that type. Is this possible?

(编辑以阐明我对添加文件关联的现有理解.)

(Edited to clarify my existing understanding of adding file associations.)

推荐答案

我有一个部分解决方案,允许设置名称(但不能设置图标或公司名称).

I have a partial solution which allows the name to be set (but not the icon or company name).

可以在 Windows 中注册一个应用程序.这与创建 ProgID,但它允许您设置 FriendlyAppName.出于某种原因,您不能在 ProgID 上设置 FriendlyAppName.不幸的是,FriendlyAppName 不是字符串,而是对 .DLL 或 .EXE 文件中资源的引用.去图.

It is possible to register an application in Windows. This is very similar to creating a ProgID, but it allows you to set the FriendlyAppName. For some reason, you can't set the FriendlyAppName on a ProgID. Unfortunately, FriendlyAppName is not a string, but a reference to a resource in a .DLL or .EXE file. Go figure.

所以:

  • 为要与文件关联的虚拟应用程序创建一个虚拟的 .dll 文件.它不必包含任何代码,只需资源即可.给它一个包含应用程序标题的字符串资源.
  • 创建一个密钥 HKEY_CLASSES_ROOT\Applications\whatever.exe(任何应该是虚拟应用程序特定的唯一名称——它不需要是一个真正的可执行文件,但它确实需要以 .exe 或其他可执行文件扩展名结尾).
    • 设置默认值,DefaultIconshell,如 程序标识符.当此关联为默认值时,这将设置文件类型的名称和图标,以及要运行的 shell 命令.
    • 还要给它一个 FriendlyAppName 值,引用虚拟 .dll.例如,如果您的应用名称字符串是字符串编号 23,请将 FriendlyAppName 设置为@PATH\TO\DLL.dll,-23".
    • 添加一个 SupportedTypes 键,并为虚拟应用程序可以处理的每种类型添加一个值.
    • Create a dummy .dll file for the virtual application with which you want to associate the file. It doesn't have to have any code in it, just resources. Give it a string resource containing the title of the application.
    • Create a key HKEY_CLASSES_ROOT\Applications\whatever.exe (whatever should be a unique name specific to the virtual application -- it does not need to be the name of a real executable, but it does need to end in .exe or another executable extension).
      • Set the default value, DefaultIcon and shell, as described in Programmatic Identifiers. This sets the name and icon for the file type when this association is the default, as well as the shell command to run.
      • Also give it a FriendlyAppName value referring to the dummy .dll. For example, if your app name string is string number 23, set FriendlyAppName to "@PATH\TO\DLL.dll,-23".
      • Add a SupportedTypes key and add a value for each type that the virtual application can handle.

      现在该应用程序将出现在选择默认程序"对话框的其他程序"下拉菜单中,但不会出现在打开方式"菜单中.要正确关联它,您需要:

      Now the application will appear in the "Other Programs" dropdown of the "Choose default program" dialog, but not in the "Open With" menu. To properly associate it, you need to:

      • 转到注册表中文件扩展名的条目.这应该在 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts(它也可以在 HKEY_CURRENT_USER,但我发现 FileExts 版本覆盖,如果用户手动创建文件关联,Windows 在那里创建一个,所以最好使用那个).
        • OpenWithList 下,需要有一个您在上面创建的伪造whatever.exe 的条目.这应该是一个名称为任意字母且值为假 exe 名称的值.
        • 同样在 OpenWithList 下,您需要确保 MRUList 值包括您在上一步中分配给假可执行文件的字母.
        • 我不相信您需要将它添加到 OpenWithProgids(没有这个也可以),但文档告诉您这样做.
        • 要使其成为默认处理程序,请在 UserChoice 下,将 Progid 设置为Applications\whatever.exe".这是可选的,但需要在此处设置一些内容(如果缺少 UserChoice,则什么都不起作用).
        • Go to the file extension's entry in the registry. This should be in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts (it can also be in HKEY_CURRENT_USER, but I have found that the FileExts version overrides, and Windows creates one there if the user manually creates a file association, so best to use that one).
          • Under OpenWithList, there needs to be an entry for the fake whatever.exe you created above. This should be a value whose name is an arbitrary letter and whose value is the fake exe name.
          • Also under OpenWithList, you need to ensure that the MRUList value includes the letter you assigned to the fake executable in the previous step.
          • I don't believe you need to add it to OpenWithProgids (it works without this), but the documentation tells you to.
          • To make it the default handler, under UserChoice, set Progid to "Applications\whatever.exe". This is optional, but there needs to be something set here (if UserChoice is missing, nothing will work).

          最后,使用 SHChangeNotify 刷新 Windows 的图标和快捷方式缓存.(毕竟我不确定这是否有必要;我只是注意到它有助于让 Windows 注意到您所做的更改.)

          Lastly, hit it with a SHChangeNotify to refresh Windows' icon and shortcut cache. (I'm not sure if this is necessary after all; I just noticed that it helps to make Windows notice the changes you're making.)

          现在在文件类型的打开方式"菜单上,您应该会看到您放入虚拟 .dll 中的自定义字符串的条目.它仍然会有 shell 命令中提到的真实二进制文件的图标,但您至少可以控制名称.为什么,为什么这么难?

          Now on the "Open With" menu for the file type, you should see an entry for the custom string you put in the dummy .dll. It will still have the icon of the real binary mentioned in the shell command, but you can at least control the name. Why, why is this so hard?

          如果有更好的答案,我会暂时搁置这个问题.

          I will leave this question open for awhile in case there are better answers.

          这篇关于Windows:更改与文件类型关联的应用程序的名称/图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆