bcb循环问题

fbCstrike 2008-07-08 02:52:47
我想读出电脑上面的注册表,现在出了点点问题。只能读出一个主键的数据,而且都没有对应正确,请帮我看看我的这个循环吧
下面是代码

AnsiString HKey[5]={"HKEY_CLASSES_ROOT","HKEY_CURRENT_USER","HKEY_LOCAl_MACHINE","HKEY_USERS","HEKY_CURRENT_CONFIG"};
void __fastcall TForm1::FormCreate(TObject *Sender)
{
reg=new TRegistryIniFile("");//创建一个注册表实例,使用缺省跟键
str=new TStringList();//创建字符串列表对象
this->RadioButton1->Checked=true;
this->RadioButton2->Checked=false;//让Reg为选中
for(int i=0;i<5;i++)
{
ComboBox1->Items->Add(HKey[i]);//将注册键添加到ComboBox1
ComboBox1->Text=HKey[0]; //为ComboBox1赋初值
TreeView1->Items->Add(NULL,HKey[i]);
Node=TreeView1->Items->Item[i];
if(reg->RegIniFile->HasSubKeys()==true)
{
reg->ReadSections(str);
for(int i=0;i<str->Count;i++)
TreeView1->Items->AddChild(Node,str->Strings[i]);
}
}

}
...全文
93 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
fbCstrike 2008-07-08
  • 打赏
  • 举报
回复
reg=new TRegistryIniFile(HKEY_CLASSES_ROOT)报错了
[C++ Error] Edit.cpp(22): E2285 Could not find a match for 'TRegistryIniFile::TRegistryIniFile(void *)'
loveshell 2008-07-08
  • 打赏
  • 举报
回复
刚才那个点问题,
reg=new TRegistryIniFile()
默认主键是HKEY_CURRENT_USER,要读HKEY_CLASSES_ROOT,应该是 reg=new TRegistryIniFile(HKEY_CLASSES_ROOT),而不是reg=new TRegistryIniFile("HKEY_CLASSES_ROOT"),几个主键是预定义的,不是字符串
fbCstrike 2008-07-08
  • 打赏
  • 举报
回复
还是不对,现在是把HKEY_CURRENT_USER放到HKEY_CLASSES_ROOT里面去了,也只显示了HKEY_CLASSES_ROOT这个
其他都没有了。
loveshell 2008-07-08
  • 打赏
  • 举报
回复
void __fastcall TForm1::FormCreate(TObject *Sender) 
{
str=new TStringList();//创建字符串列表对象
this->RadioButton1->Checked=true;
this->RadioButton2->Checked=false;//让Reg为选中
for(int i=0;i <5;i++)
{
reg=new TRegistryIniFile(HKey[i]));//创建一个注册表实例,使用缺省跟键

ComboBox1->Items->Add(HKey[i]);//将注册键添加到ComboBox1
ComboBox1->Text=HKey[0]; //为ComboBox1赋初值
TreeView1->Items->Add(NULL,HKey[i]);
Node=TreeView1->Items->Item[i];
if(reg->RegIniFile->HasSubKeys()==true)
{
reg->ReadSections(str);
for(int i=0;i <str->Count;i++)
TreeView1->Items->AddChild(Node,str->Strings[i]);
}
delete reg;
}

}
loveshell 2008-07-08
  • 打赏
  • 举报
回复
你的程序每次循环只读了缺省主键和它的下一级项

1,222

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧