procedure Tfrmmain.ResetHttpClient;
begin
try
if Assigned(httpClient) then
begin
FreeAndNil(httpClient);
end;
httpClient := TIdHTTP.Create(nil);
httpClient.HandleRedirects := True;
httpClient.Request.AcceptEncoding := '';
httpClient.ReadTimeout:= 30000;
httpClient.ConnectTimeout:= 30000;
except
end;
end;
procedure Tfrmmain.ResetstrList;
begin
try
if Assigned(strList) then
begin
FreeAndNil(strList);
end;
strList := TStringList.Create;
strList.Clear;
except
end;
end;
delphi 释放内存
最新推荐文章于 2025-03-02 16:46:43 发布
该代码段展示了如何重置并初始化TIdHTTP组件和TStringList对象。它首先检查对象是否已分配,如果已分配则释放并清空,然后重新创建HTTP客户端,设置其属性如接受编码、超时时间等。对于strList,它创建新的TStringList并清空内容。
1491

被折叠的 条评论
为什么被折叠?



