你可以试一试如下的程序:<br>因该没问题!!!!!!!<br>//--------------------------------------------------------------------<br>void __fastcall TForm1::Button1Click(TObject *Sender)<br>{<br>//HKEY_LOCAL_MACHINE/Software/下兴建了autoshut主键<br> const String RegKey = "Software//autoshut";<br> TRegistry* MyRegistry = new TRegistry();<br><br> MyRegistry->RootKey = HKEY_LOCAL_MACHINE;<br> if (!MyRegistry->OpenKey(RegKey,true))<br> {<br> ShowMessage("error");<br> }<br> delete MyRegistry;<br>}<br>//--------------------------------------------------------------------<br>void __fastcall TForm1::Button2Click(TObject *Sender)<br>{<br> const String RegKey = "Software//autoshut";<br> const String RegKey2 = "HKEY_LOCAL_MACHINE//Software//autoshut";<br> TRegistry* MyRegistry = new TRegistry();<br><br><br> MyRegistry->RootKey = HKEY_LOCAL_MACHINE;<br> if(!MyRegistry->DeleteKey("Software//autoshut"))<br> ShowMessage("error");<br> delete MyRegistry;<br>}<br>//--------------------------------------------------------------------<br>