![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
Имеется код загрузки картики:
Код:
Большой кусок кода
Memo := TMemoryStream.Create;
idHTTP1.Get('http://ru6.darkorbit.bigpoint.com'+s4,Memo);
idHTTP1.Disconnect;
Memo.SaveToFile('image.gif');
Memo.Free;
captcha:=recognize('image.gif',edit6.Text,false,false,false,0,0);
Большой кусок кодаНо второй раз вылетает ошибка в это строке: Код:
Memo.SaveToFile('image.gif');Помогите решить. |
|
#2
|
|||
|
|||
|
ап. Помогите плииз
|
|
#3
|
||||
|
||||
|
Динамически создавай idHTTP1.
|
|
#4
|
|||
|
|||
|
Цитата:
|
|
#5
|
||||
|
||||
|
Цитата:
|
|
#6
|
||||
|
||||
|
Убэдиль, просмотрел твой срЫн, ну так там же ясно написано, файло занято, значит твой рекогнайз его занимает и не отпускает.
|
|
#7
|
|||
|
|||
|
Цитата:
![]() |
|
#8
|
||||
|
||||
|
Надо смотреть под капот. Рекогнайз на каком-то объекте построен, или там дллька?
|
|
#9
|
|||
|
|||
|
Цитата:
Код:
function form1.recognize(filename, apikey: string; is_phrase, is_regsense,
is_numeric: boolean; min_len, max_len: integer): string;
var
ftype,tmpstr,captcha_id: String;
i: integer;
http: TIdHTTP;
multi: Tidmultipartformdatastream;
begin
if FileExists(filename)=false then begin result:='ERROR: file not found'; exit; end;
ftype:='image/pjpeg';
if strpos(Pchar(filename),'jpg')<>nil then ftype:='image/pjpeg';
if strpos(Pchar(filename),'gif')<>nil then ftype:='image/gif';
if strpos(Pchar(filename),'png')<>nil then ftype:='image/png';
multi:=Tidmultipartformdatastream.Create;
multi.AddFormField('method','post');
multi.AddFormField('key',apikey);
multi.AddFile('file',filename,ftype);
if is_phrase=true then multi.AddFormField('phrase','1');
if is_regsense=true then multi.AddFormField('regsense','1');
if is_numeric=true then multi.AddFormField('numeric','1');
if min_len>0 then multi.AddFormField('min_len',inttostr(min_len));
if max_len>0 then multi.AddFormField('max_len',inttostr(max_len));
http:=TIdHTTP.Create(nil);
tmpstr:=http.Post('http://antigate.com/in.php',multi);
http.Free;
captcha_id:='';
if strpos(Pchar(tmpstr),'ERROR_')<>nil then begin result:=tmpstr; exit; end;
if strpos(Pchar(tmpstr),'OK|')<>nil then captcha_id:=AnsiReplaceStr(tmpstr,'OK|','');
if captcha_id='' then result:='ERROR: bad captcha id';
for i:=0 to 20 do
begin
Application.ProcessMessages;
sleep(2000);
http:=TIdHttp.Create(nil);
tmpstr:=http.Get('http://antigate.com/res.php?key='+apikey+'&action=get&id='+captcha_id);
http.Free;
if strpos(Pchar(tmpstr),'ERROR_')<>nil then begin result:=tmpstr; exit; end;
if strpos(Pchar(tmpstr),'OK|')<>nil then
begin
result:=AnsiReplaceStr(tmpstr,'OK|','');
exit;
end;
Application.ProcessMessages;
end;
result:='ERROR_TIMEOUT';
end; |
|
#10
|
||||
|
||||
|
Пробуй:
Код:
function form1.recognize(filename, apikey: string; is_phrase, is_regsense,
is_numeric: boolean; min_len, max_len: integer): string;
var
ftype,tmpstr,captcha_id: String;
i: integer;
http: TIdHTTP;
multi: Tidmultipartformdatastream;
begin
if FileExists(filename)=false then begin result:='ERROR: file not found'; exit; end;
ftype:='image/pjpeg';
if strpos(Pchar(filename),'jpg')<>nil then ftype:='image/pjpeg';
if strpos(Pchar(filename),'gif')<>nil then ftype:='image/gif';
if strpos(Pchar(filename),'png')<>nil then ftype:='image/png';
multi:=Tidmultipartformdatastream.Create;
multi.AddFormField('method','post');
multi.AddFormField('key',apikey);
multi.AddFile('file',filename,ftype);
if is_phrase=true then multi.AddFormField('phrase','1');
if is_regsense=true then multi.AddFormField('regsense','1');
if is_numeric=true then multi.AddFormField('numeric','1');
if min_len>0 then multi.AddFormField('min_len',inttostr(min_len));
if max_len>0 then multi.AddFormField('max_len',inttostr(max_len));
http:=TIdHTTP.Create(nil);
tmpstr:=http.Post('http://antigate.com/in.php',multi);
http.Free;
captcha_id:='';
if strpos(Pchar(tmpstr),'ERROR_')<>nil then begin result:=tmpstr; exit; end;
if strpos(Pchar(tmpstr),'OK|')<>nil then captcha_id:=AnsiReplaceStr(tmpstr,'OK|','');
if captcha_id='' then result:='ERROR: bad captcha id';
for i:=0 to 20 do
begin
Application.ProcessMessages;
sleep(2000);
http:=TIdHttp.Create(nil);
tmpstr:=http.Get('http://antigate.com/res.php?key='+apikey+'&action=get&id='+captcha_id);
http.Free;
if strpos(Pchar(tmpstr),'ERROR_')<>nil then begin result:=tmpstr; exit; end;
if strpos(Pchar(tmpstr),'OK|')<>nil then
begin
result:=AnsiReplaceStr(tmpstr,'OK|','');
exit;
end;
Application.ProcessMessages;
end;
result:='ERROR_TIMEOUT';
multi.free;
end; |
|
#11
|
|||
|
|||
|
Цитата:
![]() P.s. Все равно та же ошибка. Последний раз редактировалось babay89, 13.11.2011 в 00:40. |
|
#12
|
|||
|
|||
|
UP!!! Проблема актуальна.
|
|
#13
|
|||
|
|||
|
на крайний случай можно менять имена файлов)
|
|
#14
|
|||
|
|||
|
Цитата:
![]() |
|
#15
|
||||
|
||||
|
так ты разберись со своим функционалом, так прям поле чудес какое-то "угадай где баг". или весь свой сорс выложи.
|