Chinaunix首页 | 论坛 | 博客
  • 博客访问: 92335605
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: C/C++

2008-04-16 18:57:48

    来源:赛迪网社区    作者:NO1

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;

阅读(223) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~