Setting up File associations

北战南征 提交于 2020-02-07 05:46:29

问题


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:

Sample Names

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.

Registry Locations (where I have added to)

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 :(

File Images

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?

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 :(


回答1:


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:

File Types and File Associations

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 Key

Merged View of HKEY_CLASSES_ROOT



来源:https://stackoverflow.com/questions/8684027/setting-up-file-associations

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!