设置文件关联 [英] Setting up File associations

查看:71
本文介绍了设置文件关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图让Windows识别程序的文件扩展名,但与往常一样运气不佳.

I am trying to get Windows to recognise my program's File extensions but without much luck, as usual.

这是我正在做的,请告知我在哪里或做错了什么-我想我可能是注册表位置或命名设置不正确:

This is what I am doing, please advise where or what I am doing wrong - I think I might have the registry locations or naming set incorrectly:

样品名称

MyProg.exe = The name of the program.
%InstallPath% = Where the program will be installed.
.ext1 = 1st File Extension.
.ext2 = 2nd File Extension.
.ext3 = 3rd File Extension.

注册表位置(我添加到的位置)

HKEY_CLASSES_ROOT\.ext1
HKEY_CLASSES_ROOT\.ext2
HKEY_CLASSES_ROOT\.ext3

HKEY_CLASSES_ROOT\.ext1\DefaultIcon,2
HKEY_CLASSES_ROOT\.ext1\shell\open\command\%InstallPath%\MyProg.exe %1

那之后我有点迷失了:(

I got kind of lost off after that :(

文件图像

我已经从XE IDE资源菜单中添加了3个图标文件,并将它们命名为2,3,4.我想如果我有一个名为1的图标,它将覆盖项目图标吗?

I have added the 3 icon files from the XE IDE Resources Menu, and named them 2,3,4. I think if I have an Icon named 1, it will override the Project icon?

我想在从未安装过程序的计算机上使用Inno Setup之类的安装程序之前,先使它们正常工作(以查看安装是否完美无缺).

I want to get these working right before using an installer such as Inno Setup on a machine that has never seen my program (to see if the installation was flawless).

我找不到任何易于遵循的指南:(

I can't find any easy to follow guides :(

推荐答案

您设置的注册表项错误.您需要将文件扩展名与ProgID关联,然后将ProgID与您的应用程序关联,如下所示:

You are setting up the Registry keys wrong. You need to associate the file extensions with ProgIDs, then associate the ProgIDs with your app, like this:

HKEY_CLASSES_ROOT\.ext1 
(Default) = "ext1File"

HKEY_CLASSES_ROOT\.ext2 
(Default) = "ext2File"

HKEY_CLASSES_ROOT\.ext3 
(Default) = "ext3File"

HKEY_CLASSES_ROOT\ext1File\DefaultIcon
(Default) = "%InstallPath%\MyProg.exe,2" 

HKEY_CLASSES_ROOT\ext1File\shell\open\command
(Default) = ""%InstallPath%\MyProg.exe" "%1""

HKEY_CLASSES_ROOT\ext2File\DefaultIcon
(Default) = "%InstallPath%\MyProg.exe,3" 

HKEY_CLASSES_ROOT\ext2File\shell\open\command
(Default) = ""%InstallPath%\MyProg.exe" "%1""

HKEY_CLASSES_ROOT\ext3File\DefaultIcon
(Default) = "%InstallPath%\MyProg.exe,4" 

HKEY_CLASSES_ROOT\ext3File\shell\open\command
(Default) = ""%InstallPath%\MyProg.exe" "%1""

阅读以下文档以了解更多详细信息:

Read the following documentation for more details:

文件类型和文件关联

仅供参考,您不应该直接将数据写入 HKEY_CLASSES_ROOT .改为写入 HKEY_CURRENT_USER \ Software \ Classes 和/或 HKEY_LOCAL_MACHINE \ Software \ Classes ,具体取决于您是要按用户注册还是要在计算机全局注册.阅读以下文档以获取有关原因的更多详细信息.

FYI, you should not be writing data to HKEY_CLASSES_ROOT directly. Write to either HKEY_CURRENT_USER\Software\Classes and/or HKEY_LOCAL_MACHINE\Software\Classes instead, depending on whether you want per-user or machine-global registration. Read the following documentation for more details as to why.

HKEY_CLASSES_ROOT键

HKEY_CLASSES_ROOT的合并视图

这篇关于设置文件关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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