try
{
string MyFileName = AppSetter.SysInfoPath + @"\DrawTools\csg.exe";
string MyExtName = ".csg";
string MyType = "csgfile";
RegistryKey key = Registry.ClassesRoot.OpenSubKey(MyExtName);
if (key == null || key.ValueCount == 0)
{
RegistryKey MyReg = Registry.ClassesRoot.CreateSubKey(MyExtName);
MyReg.SetValue("", MyType);
MyReg = MyReg.CreateSubKey("shell\\open\\command");
MyReg.SetValue("", MyFileName + " %1");
MyReg.Close();
}
else if (!key.GetValue("").ToString().Equals(MyType))
{
key.DeleteSubKeyTree(MyExtName);
RegistryKey MyReg = Registry.ClassesRoot.CreateSubKey(MyExtName);
MyReg.SetValue("", MyType);
MyReg = MyReg.CreateSubKey("shell\\open\\command");
MyReg.SetValue("", MyFileName + " %1");
MyReg.Close();
}
}
catch (Exception ex)
{
Tools.Trace("Program:Main error:" + ex.ToString());
}