user741875
user741875

Reputation:

Setting up File associations

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

Upvotes: 0

Views: 1110

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 595837

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

Upvotes: 5

Related Questions