当前位置:首页 >> 编程开发 >> Visual C++ >> 内容

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

时间:2008/1/5 作者:平凡之路 来源:xuhantao.com 浏览:

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\\Current\
                 Version\\Run",true)) //打开主键
   //这样双引号里面的东西就变成了CurrentKey
   {
     Application->MessageBox("注册表内容无效",
                 "读取注册表出错",MB_ICONERROR);
     MyRegistry->CloseKey();
     delete MyRegistry;
     return;
     }
   MyRegistry->WriteString("myrun","c:\\sthvcd\\sthvcd.exe");
   MyRegistry->CloseKey();
   delete MyRegistry;

相关文章
  • 没有相关文章
  • 徐汉涛(www.xuhantao.com) © 2024 版权所有 All Rights Reserved.
  • 部分内容来自网络,如有侵权请联系站长尽快处理 站长QQ:965898558(广告及站内业务受理) 网站备案号:蒙ICP备15000590号-1