首页 新闻 会员 周边 捐助

C#&&注册表

0
悬赏园豆:40 [已关闭问题] 关闭于 2009-05-23 08:56
<table style="height: 100%;" border="0" cellspacing="0"> <tbody> <tr> <td id="Topic_Body" class="content">这是add.reg文件的类容 <br /><br />Windows Registry Editor Version 5.00 <br /><br />[HKEY_CLASSES_ROOT\Directory\shell\q_Cmd_Here\command] <br />@="cmd.exe /k cd %1" <br /><br />[HKEY_CLASSES_ROOT\*\shell\q_Cmd_Here\command] <br />@="cmd.exe" <br /><br />[HKEY_CLASSES_ROOT\Drive\shell\q_Cmd_Here\command] <br />@="cmd.exe /k cd %1" <br /><br /><br />这是添加到鼠标右键的FrmSetLeftKey.cs窗体button1添加,button2移除 <br />&nbsp; private void button1_Click(object sender, EventArgs e) <br />&nbsp; &nbsp; &nbsp; &nbsp; { <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { <br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RegistryKey reg; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reg = Registry.ClassesRoot; <br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reg = Registry.ClassesRoot; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reg.CreateSubKey(@"*\shell\删除图片\command"); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //创建新项command <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reg = Registry.ClassesRoot.OpenSubKey(@"*\shell\删除图片\command", true); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reg.SetValue("", Application.ExecutablePath + " %1"); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //设置command的值 <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reg.Close(); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.Show("添加成功!"); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; catch (Exception ex) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.Show(ex.ToString()); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />&nbsp; &nbsp; &nbsp; &nbsp; } <br /><br />&nbsp; &nbsp; &nbsp; &nbsp; private void button2_Click(object sender, EventArgs e) <br />&nbsp; &nbsp; &nbsp; &nbsp; { <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RegistryKey reg; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reg = Registry.ClassesRoot; <br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reg = Registry.ClassesRoot; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reg.DeleteSubKey(@"*\shell\删除图片\command",false); <br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reg.Close(); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.Show("移除成功!"); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; catch(Exception ex) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.Show(ex.ToString()); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />&nbsp; &nbsp; &nbsp; &nbsp; } <br /><br /><br />问题一:&nbsp; 我怎样添加我自己的一个form作为右键弹出的对象(应该是这一句:reg.SetValue("", Application.ExecutablePath + " %1");但看不懂) <br /><br />问题二FrmSetLeftKey.cs窗体的button2移除右键不会移除右键请csdn上朋友修改下。 </td> </tr> <tr> <td class="modify">&nbsp;</td> </tr> </tbody> </table>
大头爷爷的主页 大头爷爷 | 初学一级 | 园豆:0
提问于:2009-05-20 20:43
< >
分享
所有回答(1)
0

这里是CNBLOGS,抱歉兄台,你走错地方了。  

404-error | 园豆:265 (菜鸟二级) | 2009-05-20 22:54
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册