111,125
社区成员
发帖
与我相关
我的任务
分享
try
{
string notepath = @"D:\C#\TalentPlay\TalentPlay\bin\Release\TalentPlay.exe";//记事本应用程序路径
string extName = ".mp4";//要创建子项的名称
string mtype = "我定义的类型";
string mContent = "text/plain";
RegistryKey mreg;
RegistryKey mreg2;
mreg = Registry.ClassesRoot;//获取指定基项
mreg = mreg.CreateSubKey(extName);//在指定基项下创建新子项“.mp4”
mreg.SetValue("", mtype);//设置.ls子项的“默认键”对应的值为“我定义的类型”
mreg.SetValue("Content Type", mContent);//设置设置.mp4子项的“Content Type键”对应的值为“text/plain”
mreg2 = mreg.CreateSubKey("DefaultIcon");//在.mp4子项下创建新的子项“DefaultIcon”
mreg2.SetValue("", @"C:\Users\Administrator\Desktop\5332\5332\documentsfolder.ico");//设置“shell\\open\\command”子项的“默认键”对应的值为“C:\WINDOWS\notepad.exe %1”
mreg = mreg.CreateSubKey("shell\\open\\command");//在.mp4子项下创建新的子项“shell\\open\\command”
mreg.SetValue("", notepath + " %1");//设置“shell\\open\\command”子项的“默认键”对应的值为“C:\WINDOWS\notepad.exe %1”
mreg2.Close();
mreg.Close();//关闭该项,如果该项的内容已修改,则将该项刷新到磁盘。
if (MessageBox.Show("设置完毕") == DialogResult.OK)
{
RefreshSystem();//刷新explorer进程
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}


