File associations in Windows are done through registry keys. Two keys need to be entered for each file extension, both under the HKEY_CLASSES_ROOT key. The first is the File Name Extension Key which specifies the class definition associated with files that have that extension. For example, if I wanted to associate the *.ext file extension with my application, I would add the key:
KEY
Name
Data
HKEY_CLASSES_ROOT\.ext
(Default)
"MyAppType"
The second key is the Class Definition Key which the extension was associate with. This key contains types of actions, referred to a verbs, which can be performed on the file. In this case we are only concerned with the Open verb which will define the command line for opening our file.
KEY
Name
Data
HKEY_CLASSES_ROOT\MyAppType\shell\open\command
(Default)
"C:\Program Files\MyApplication\MyApplication.exe %1"
Notice here the "%1" tag which is added to the command string. This tag will be replaced by the name of the file you click on. The file name and path is thus accessible to your application as a command line parameter. Your application will have to be designed to read command line parameters in order to actually open the file which was clicked on.
If you choose to, you can also associate an icon with your custom file type:
KEY
Name
Data
HKEY_CLASSES_ROOT\MyAppType\DefaultIcon
(Default)
"C:\Program Files\MyApplication\MyIcon.ico,0"
Executables and ICO files often contain multiple icons, so it is important to follow the file path with the icon's resource index (0 for regular ICO files). If you do associate an icon to your file, you may also want to call the SHChangeNotify function from the Windows Shell32.dll. This function notifies the system that changes have been made so that the changes can be immediately applied. If you do not call this function, your icon may not be used for your file extension until the system reboots.
Editing the Registry keys in CVI (or anything else) will require some windows API calls. The calls should all be in the Advapi32.dll. Look for info on functions like RegCreateKeyExA and RegSetValueExA in MSDN.
Good Luck
Amaury R.
NI Applications Engineer