Have you ever wondered how installation programs are able to associate a file extension with a program? Or how when you double click on a MS Word file, Microsoft Word automatically starts up and loads that particular file? Well, in this article I will explain how it is done.
Create a new registry key and add the extension, then add the program name and enable it to accept parameters as follows:
reg.OpenKey('.'+edExt.Text+'shellopencommand', true) then begin reg.WriteString('', edappname.Text+' %1 '); reg.CloseKey;
The next section of the procedure associates the extension with a icon, similar to the way MS Word associates all the ".doc" files with its icon. The first icon in an exe is usually the "defaulticon" or icon number "0." The code snippet below is responsible for associating the extension with the icon:
reg.OpenKey('.'+edExt.Text+'DefaultIcon', true); {Use the first icon in the executable to display} reg.WriteString('', edappname.Text+',0'); reg.CloseKey;
That's it. Now, after you've associated an extension with an application, the actual application also needs to be able to accept parameters.