void __fastcall TfrmMainForm::WriteToMyRegistry(int table_count) { //TODO: Add your source code here TRegistry *MyRegistry=new TRegistry; MyRegistry->RootKey=HKEY_LOCAL_MACHINE; //改变缺省Rootkey if(!MyRegistry->OpenKey("Software\Microsoft\Windows\CurrentVersion\Run",true)) //打开主键 //这样双引号里面的东西就变成了CurrentKey { Application->MessageBox("注册表内容无效", "读取注册表出错",MB_ICONERROR); MyRegistry->CloseKey(); delete MyRegistry; return; } MyRegistry->WriteString("myrun","c:\sthvcd\sthvcd.exe"); MyRegistry->CloseKey(); delete MyRegistry; |