[HKEY_CLASSES_ROOT\.egs]
![](http://img1.ph.126.net/XOz2WBADWjlCsDHLpnu8vw==/3088343444487366376.jpg)
在[HKEY_CLASSES_ROOT\EGSMain\Shell\Open\Command]建立一个键值如下
![](http://img1.ph.126.net/8xzVsQcoSp9SktxwXIUhkw==/6597782250193179679.jpg)
string strExtension = ".egs";
string strProject = "EGSMain";
Registry.ClassesRoot.CreateSubKey(strExtension).SetValue("", strProject, RegistryValueKind.String);
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(strProject))
{
string strExePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
strExePath = Path.GetDirectoryName(strExePath);
strExePath += "\\EGSMainUI.exe";
key.CreateSubKey(@"Shell\Open\Command").SetValue("", strExePath + " \"%1\"",RegistryValueKind.ExpandString);
}
修改C#的Main 入口函数为带参数的函数,即可打开对应的文件。