我写的你要不要??
//向注册表中写入数据
procedure WriteValues(Registry:TRegistry;ValueNames:array of String;Values:array of Variant);
var
I:Integer;
ValueName:String;
Value:Variant;
begin
if Length(ValueNames)=Length(Values) then
with Registry do
for I:=0 to Length(ValueNames)-1 do
begin
ValueName:=ValueNames;
Value:=Values;
case VarType(Value) of
varString : WriteString(ValueName,Value);
varBoolean: WriteBool(ValueName,Value);
varByte,
varSmallInt,
varInteger: WriteInteger(ValueName,Value);
end;
end;
end;
//读取注册表某键值中所有数据
procedure ReadRegistValues(ARootKey:HKEY;Key:String;Values:TStrings);
var
I:Integer;
begin
with TRegistry.Create do
try
RootKey:=ARootKey;
OpenKey(Key,False);
Values.Clear;
GetValueNames(Values);
for I:=0 to Values.Count-1 do
Values:=Values+'='+ReadString(Values);
finally
Free;
end;
end;
//向注册表中写入字符串值
procedure WriteRegistString(ARootKey:HKEY;Key,Name,Value:String);
begin
with TRegistry.Create do
try
RootKey:=ARootKey;
OpenKey(Key,True);
WriteString(Name,Value);
finally
Free;
end;
end;
//读取注册表中的字符串值
function ReadRegistString(ARootKey:HKEY;Key,Name:String;DefaultValue:String=''):String;
begin
Result:=DefaultValue;
with TRegistry.Create do
try
RootKey:=ARootKey;
OpenKey(Key,False);
try
Result:=ReadString(Name);
except
end;
finally
Free;
end;
end;
其他如读写整数值、布尔值与上面类似,
TRegistry的Read/Write:
BianryData、Bool、Currency、Date、Time、DateTime、Integer、String方法而已