Register the association for every user, write your data to
Register the association for the current user only, write your data to
This will associate .test files, called "MyTest For Text File" so that they will have the icon of notepad.exe and will be opened bynotepad.exe. The last line tells Explorer to 'reload' itself to reflect the changes made to the file associations. For instance, Explorer file list views will update. The WinAPI function SHChangeNotify is declared in ShlObj.pas, so you need to uses ShlObj.
Notice that the %1 in shell\open\command will expand to the current file. For instance, if you double-click on C:\some dir\atxtfile.test, then Explorer will execute the command.
C:\WINDOWS\notepad.exe "C:\some dir\atxtfile.test"