如何操作注册表
如何操作注册表
#include <Registry.hpp>
TRegIniFile *Reg=new TRegIniFile("SOFTWARE\\ahao's Softwares\\Wenku\\Config");
//读:
Edit2->Text=Reg->ReadString("SMTP","Host","");
Edit3->Text=IntToStr(Reg->ReadInteger("SMTP","Port",25));
Edit4->Text=Reg->ReadString("SMTP","UserID","");
//写:
Reg->WriteString("SMTP","Host",Edit2->Text);
Reg->WriteInteger("SMTP","Port",StrToInt(Edit3->Text));
Reg->WriteString("SMTP","UserID",Edit4->Text);
别忘了 Reg->Free();
RootKey是注册表的根键值,比如运行regedit后看到的HKEY_USERS,HKEY_LOCAL_MACHINE就是RootKey,在TRegIniFile中缺省的RootKey
是HKEY_USERS.
TRegistry *MyRegistry=new TRegistry;
MyRegistry->RootKey=HKEY_LOCAL_MACHINE;
//改变缺省Rootkey
[ 本帖最后由 sflt 于 2008-4-27 22:12 编辑 ]