C++builder编程修改注册表的问题

来源:网络时间:2021-10-25 00:12:31
  rootKey是注册表的根键值,比如运行regedit后看到的HKEY_USERS,HKEY_LOCAL_MACHINE就是RootKey,在TRegIniFile中缺省的RootKey是HKEY_USERS.
 
  下面的例子是TRegistry的,TRegIniFile也差不多
  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;
本文内容为用户投稿,该文观点仅代表作者本人,不代表本站立场,本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请将相关资料发送至[email protected]进行反馈与投诉,一经查实,立即处理!