有关删除注册表(50分)

  • 主题发起人 主题发起人 wzpok
  • 开始时间 开始时间
W

wzpok

Unregistered / Unconfirmed
GUEST, unregistred user!
我第一次操作注册表 &nbsp;在 &nbsp;HKEY_LOCAL_MACHINE/Software/下兴建了autoshut主键。主键下有若干键值 <br>但不知用什么方法删除autoshut 主键及其下面的键值!
 
运行regedit,在目录树中找HKEY_LOCAL_MACHINE/Software/autoshut主键,<br>用右键点autoshut,从弹出菜单中选删除。就没有了。<br>另外,你是不是想在程序里删除?
 
你可以试一试如下的程序:<br>因该没问题!!!!!!!<br>//--------------------------------------------------------------------<br>void __fastcall TForm1::Button1Click(TObject *Sender)<br>{<br>//HKEY_LOCAL_MACHINE/Software/下兴建了autoshut主键<br>&nbsp; &nbsp;const String RegKey = "Software//autoshut";<br>&nbsp; &nbsp;TRegistry* MyRegistry = new TRegistry();<br><br>&nbsp; &nbsp;MyRegistry-&gt;RootKey = HKEY_LOCAL_MACHINE;<br>&nbsp; &nbsp;if (!MyRegistry-&gt;OpenKey(RegKey,true))<br>&nbsp; &nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;ShowMessage("error");<br>&nbsp; &nbsp;}<br>&nbsp; &nbsp;delete MyRegistry;<br>}<br>//--------------------------------------------------------------------<br>void __fastcall TForm1::Button2Click(TObject *Sender)<br>{<br>&nbsp; &nbsp;const String RegKey = "Software//autoshut";<br>&nbsp; &nbsp;const String RegKey2 = "HKEY_LOCAL_MACHINE//Software//autoshut";<br>&nbsp; &nbsp;TRegistry* MyRegistry = &nbsp;new TRegistry();<br><br><br>&nbsp; &nbsp;MyRegistry-&gt;RootKey = HKEY_LOCAL_MACHINE;<br>&nbsp; &nbsp;if(!MyRegistry-&gt;DeleteKey("Software//autoshut"))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowMessage("error");<br>&nbsp; &nbsp;delete MyRegistry;<br>}<br>//--------------------------------------------------------------------<br>
 
&nbsp;aReg := TRegistry.create;<br>&nbsp; aReg.RootKey := HKEY_LOCAL_MACHINE;<br>&nbsp; aReg.OpenKey('Software', False);<br>&nbsp; aReg.deletekey('autoshut');<br>&nbsp; aReg.Free;<br>
 
当然是在程序中操作注册表
 
wzpok 我的程序你试了没有???<br>
 
不是很清楚希望继续讨论
 
第一步:<br>&nbsp; &nbsp;建立变量TRegistry* MyRegistry = new TRegistry();<br>第二步:<br>&nbsp; &nbsp;设定变量 MyRegistry的RootKey为HKEY_LOCAL_MACHINE,或HKEY_CLASSES_ROOT,HKEY_CURRENT_USER,HKEY_USERS,HKEY_CURRENT_CONFIG,<br>HKEY_DYN_DATA,这是指您键表的根值.<br>第三步:<br>&nbsp; &nbsp;用MyRegistry-&gt;OpenKey(RegKey,true)打开相应键表,RegKey设置目录为"Software//autoshut",然后就可以读数据了.<br>第四步:<br>&nbsp; &nbsp;用MyRegistry-&gt;DeleteKey("Software//autoshut")可以删除,autoshut下所有的键值.<br>够清楚了吧!<br><br>分分啰!!!!!!:-)<br>
 
你到底想怎样,上面几位大侠已讲得够清楚了。<br>建立注册表构件,TRegistry.Create<br>指定根路径,如“HKEY_LOCAL_MACHINE”<br>打开指定路径,如“Software”<br>操作指定键值,如“AutoShut”的OpenKey,DeleteKey等编辑操作<br>&nbsp; &nbsp; 至此你已完成对键“//HKEY_LOCAL_MACHINE/SoftWare/AutoShut”的操作<br>关闭注册表构件,Free<br>这是简单的标准顺序,你还想怎样?大家说的肯定是一样的。<br>
 
后退
顶部