我的代码会出错。执行的时候结果是HttpWillstart
create IE
http://192.168.0.11/posttest1/account.aspx
Access violation at address 540D0000. Read of address 540D0000代码如下
procedure TWriteTime.Execute;
var
f: TextFile;
fn: string;
sResponseText : string;
webinfo : TIdHTTP;
nIndex : integer;
begin
nIndex := 0;
fn := 'd:\s.txt';
webinfo := TIdHTTP.Create(nil);
if not FileExists(fn) then
exit;
while not Terminated do
begin
if nIndex = 0 then
begin
AssignFile(f, fn);
Append(f);
Writeln(f,'HttpWillstart');
Flush(f);
CloseFile(f);
Sleep(1000); webinfo.MaxLineAction := maException;
webinfo.ReadTimeout := 0;
webinfo.AllowCookies := True;
webinfo.ProxyParams.BasicAuthentication := False;
webinfo.ProxyParams.ProxyPort := 0;
webinfo.Request.ContentLength := -1;
webinfo.Request.ContentRangeEnd := 0;
webinfo.Request.ContentRangeStart := 0;
webinfo.Request.ContentType := 'text/html';
webinfo.Request.Accept := 'text/html, */*';
webinfo.Request.BasicAuthentication := False;
webinfo.Request.UserAgent := 'Mozilla/3.0 (compatible; Indy Library)';
AssignFile(f, fn);
Append(f);
Writeln(f,'create IE');
Flush(f);
CloseFile(f);
webinfo.Free;
Sleep(3000); AssignFile(f, fn);
Append(f);
Writeln(f,AccountWEBURL);
Flush(f);
CloseFile(f);
webinfo.Free;
Sleep(3000);
try
//就是这里出错了。
sResponseText := webinfo.Get(AccountWEBURL);
except
on E: Exception do
begin
AssignFile(f, fn);
Append(f);
Writeln(f,E.Message);
Flush(f);
CloseFile(f);
webinfo.Free;
Sleep(3000);
end;
end;
AssignFile(f, fn);
Append(f);
Writeln(f,sResponseText);
Flush(f);
CloseFile(f);
webinfo.Free;
Sleep(3000);
AssignFile(f, fn);
Append(f);
Writeln(f,'get web info');
Flush(f);
CloseFile(f);
webinfo.Free;
Sleep(3000);
AssignFile(f, fn);
Append(f);
Writeln(f,'HttpWillEnd\r\n');
Flush(f);
CloseFile(f);
Sleep(3000);
inc(nIndex);
end;
end;
end;
create IE
http://192.168.0.11/posttest1/account.aspx
Access violation at address 540D0000. Read of address 540D0000代码如下
procedure TWriteTime.Execute;
var
f: TextFile;
fn: string;
sResponseText : string;
webinfo : TIdHTTP;
nIndex : integer;
begin
nIndex := 0;
fn := 'd:\s.txt';
webinfo := TIdHTTP.Create(nil);
if not FileExists(fn) then
exit;
while not Terminated do
begin
if nIndex = 0 then
begin
AssignFile(f, fn);
Append(f);
Writeln(f,'HttpWillstart');
Flush(f);
CloseFile(f);
Sleep(1000); webinfo.MaxLineAction := maException;
webinfo.ReadTimeout := 0;
webinfo.AllowCookies := True;
webinfo.ProxyParams.BasicAuthentication := False;
webinfo.ProxyParams.ProxyPort := 0;
webinfo.Request.ContentLength := -1;
webinfo.Request.ContentRangeEnd := 0;
webinfo.Request.ContentRangeStart := 0;
webinfo.Request.ContentType := 'text/html';
webinfo.Request.Accept := 'text/html, */*';
webinfo.Request.BasicAuthentication := False;
webinfo.Request.UserAgent := 'Mozilla/3.0 (compatible; Indy Library)';
AssignFile(f, fn);
Append(f);
Writeln(f,'create IE');
Flush(f);
CloseFile(f);
webinfo.Free;
Sleep(3000); AssignFile(f, fn);
Append(f);
Writeln(f,AccountWEBURL);
Flush(f);
CloseFile(f);
webinfo.Free;
Sleep(3000);
try
//就是这里出错了。
sResponseText := webinfo.Get(AccountWEBURL);
except
on E: Exception do
begin
AssignFile(f, fn);
Append(f);
Writeln(f,E.Message);
Flush(f);
CloseFile(f);
webinfo.Free;
Sleep(3000);
end;
end;
AssignFile(f, fn);
Append(f);
Writeln(f,sResponseText);
Flush(f);
CloseFile(f);
webinfo.Free;
Sleep(3000);
AssignFile(f, fn);
Append(f);
Writeln(f,'get web info');
Flush(f);
CloseFile(f);
webinfo.Free;
Sleep(3000);
AssignFile(f, fn);
Append(f);
Writeln(f,'HttpWillEnd\r\n');
Flush(f);
CloseFile(f);
Sleep(3000);
inc(nIndex);
end;
end;
end;
引用:
////////////////////
webinfo.Free;
Sleep(3000);
try
//就是这里出错了。
sResponseText := webinfo.Get(AccountWEBURL);
///////////////////////////////////////