当前位置:天才代写 > tutorial > C语言/C++ 教程 > C++builder编程修改注册表的问题

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

2017-11-05 08:00 星期日 所属: C语言/C++ 教程 浏览:449

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;

 

    关键字:

天才代写-代写联系方式