idhttp1在线程中为啥会出错啊?
DELPHI中运行会有类似这样的错误,
Project1.exe faulted with message: 'access violation at 0x00406761: write of address 0x01de0e08'. Process Stopped. Use Step or Run to continue.
如果直接运行程序,有时还有个提示出错了,有时什么提示也没有就退出了
for i:=1 to 20 do
CreateThread(nil, 0, @CheckAcc, pointer(id), 0, dwThreadID);
procedure CheckAcc(vid:Integer);stdcall;
var
str:String;
idhttp1:TIdHTTP;
begin
try
idhttp1:=TIdHttp.Create;
str:=idhttp1.Get('http://www.163.com/');
except
idhttp1.Free;
exit;
end;
idhttp1.Free;
end;
[解决办法]
如果你不想用TThread那就用BeginThread代替CreateThread吧。