C
cnsyj
Unregistered / Unconfirmed
GUEST, unregistred user!
请大家看看我这样写的异常处理对不对!!!
try
try
tmpread:=TRegistry.Create;
tmplist:=TStringList.Create;
tmpread.RootKey:=HKEY_LOCAL_MACHINE;
if tmpread.openkey('SOFTWARE/Microsoft/Windows/CurrentVersion/run',false) then
begin
tmpread.GetValueNames(tmplist);
tmpint:=tmplist.Count;
while tmpint > 0 do
begin
tmpint:=tmpint-1;
tmpa:=tmplist.ValueFromIndex[tmpint];
tmpb:=tmpread.ReadString(tmplist.Strings[tmpint]);
with listview1.Items.Add do
begin
caption:=tmpa;
subitems.Add(tmpb);
end;
end;
end;
finally
tmplist.Free;
tmpread.Free;
end;
except
tmplist.Free;
tmpread.Free;
showmessage('读取HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/run下数据错误!')
end;
try
try
tmpread:=TRegistry.Create;
tmplist:=TStringList.Create;
tmpread.RootKey:=HKEY_LOCAL_MACHINE;
if tmpread.openkey('SOFTWARE/Microsoft/Windows/CurrentVersion/run',false) then
begin
tmpread.GetValueNames(tmplist);
tmpint:=tmplist.Count;
while tmpint > 0 do
begin
tmpint:=tmpint-1;
tmpa:=tmplist.ValueFromIndex[tmpint];
tmpb:=tmpread.ReadString(tmplist.Strings[tmpint]);
with listview1.Items.Add do
begin
caption:=tmpa;
subitems.Add(tmpb);
end;
end;
end;
finally
tmplist.Free;
tmpread.Free;
end;
except
tmplist.Free;
tmpread.Free;
showmessage('读取HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/run下数据错误!')
end;