Registry.SetValue(HKEY_CLASSES_ROOT, ".ext", "", "Software Name", REG_SZ);
Registry.SetValue(HKEY_CLASSES_ROOT, "Software Name\\shell\\open\\command", "", SessionVar.Expand("\"%AppFolder%\\MyApplication.exe\" \"%1\""), REG_SZ);
Registry.SetValue(HKEY_CLASSES_ROOT, "Software Name\\DefaultIcon", "", SessionVar.Expand("%AppFolder%\\MyApplication.exe,0"), REG_SZ);
Where ".ext" is the file extension for your software data files, "Software Name" is the title of your software, and "MyApplicaton.exe" is the executable file which loads the data files as its parameter. I supposed that you already added the icon of your software to the Setup Factory as DefaultIcon.
Everything is done with the above piece of code; but you need to restart your computer for the file association to work with the new extension.
There is another solution to complete the task directly from the Setup Factory without restarting the windows. You just need to add the below line to the above code:
DLL.CallFunction(_SystemFolder.."\\Shell32.dll", "SHChangeNotify", "134217728, 0, 0, 0", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
That's all. Everything should be worked fine now.
No comments:
Post a Comment