TRegistry
GetKeyNames
GetValueNames
GetKeyNames
GetValueNames
解决方案 »
- 在 DLL 中怎么修改 Form.Font
- 控件前端显示 问题 急!
- 变换背景图片。急,谢谢各位了
- 如何实现两个Listbox同步.高分悬赏
- 紧急:IXMLNode除了使用chridList.Delete功能外,有没有直接删除指定结点的方法?
- 关于Combobox
- Delphi指定目录程序
- 用delphi做菜单一般有什么用?
- 我以前在delphi写代码时候,左边有1条条,鼠标点1下,f9程序就运行到光标处,现在找不到它了
- 如何关闭winexec函数调出的可执行程序?
- DirectoryExists('A:\')为什么返回值为FALSE?调用SelectDirectory选择A:为什么报I/O出错?
- 怎样升级F1Book成6.1
在Tregistry类中还提供了与Write方法相对应用的用来读出与当前关键字相关的数据值。常用方法的原型定义如下:
founction ReadString(const Name : string) : string;
founction ReadInteger(const Name : string) : Integer;
founction ReadFloat(const Name : string) : Double;
founction ReadTime(const Name : string) : TdateTime;
founction ReadBool(const Name) : Boolean;
示例程序如下:
procedure TForm1.Button1Click(Sender: TObject);
var
MyReg : TRegistry;
begin
MyReg := TRegistry.Create;
MyReg.RootKey := HKEY_LOCAL_MACHINE;
try
if not MyReg.OpenKey('SOFTWARE',FALSE) then ;
if not MyReg.KeyExists('Passwd') then ;
if not MyReg.OpenKey('SOFTWAREPasswd',FALSE) then ;
Label1.Caption := MyReg.ReadString('pwd1');
Label2.Caption := IntToStr(MyReg.ReadInteger('pd2'));
MyReg.CloseKey;
finally
MyReg.Free;
end;
end;
Reg: TRegistry;
KeyNames, ValueNames: TStringList;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE; //这里可能需要按自己的需要来修改
if Reg.OpenKey(……,False) then //在省略号处填入要读取的键名
begin
KeyNames := TStringList.Create
try
Reg.GetKeyNames(KeyNames);
…… //进行需要的操作
finally
KeyNames.Free;
end; ValueNames := TStringList.Create
try
Reg.GetValueNames(ValueNames);
…… //进行需要的操作
finally
KeyNames.Free;
end;
end;
finally
Reg.Free;
end;
end;