Андрей
Принятый Кодер
- Регистрация
- 17 Дек 2015
- Сообщения
- 58
- Баллы
- 60
Необъявленный идентификатор 'PosEx'
Я прокомментировал в коде ошибку
Я прокомментировал в коде ошибку
Код:
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IdCookieManager, IdIOHandler,
IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL, IdBaseComponent,
IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, Vcl.StdCtrls, sGroupBox,
sButton, sEdit, Jpeg, Vcl.ExtCtrls;
type
TForm2 = class(TForm)
sEdit1: TsEdit;
sEdit2: TsEdit;
sButton1: TsButton;
sGroupBox1: TsGroupBox;
sButton2: TsButton;
sButton3: TsButton;
sButton4: TsButton;
sButton5: TsButton;
IdHTTP1: TIdHTTP;
IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
IdCookieManager1: TIdCookieManager;
Image1: TImage;
procedure sButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.sButton1Click(Sender: TObject);
var data:tstringlist;
PageProfile, pic:string;
error:boolean;
beginpos, endpos : Integer;
ms: TMemoryStream;
jpeg: TJpegImage;
begin
IdHTTP1.AllowCookies:=true;
IdHTTP1.HandleRedirects:=false;
data:=tstringlist.create;
data.Add('email=sEdit1.text');
data.Add('pass=sEdit2.text');
data.Add('expire=');
data.Add('vk=');
error:=false;
try
PageProfile:=IdHTTP1.Post('http://login.vk.com/?act=login', data);
except
error:=true;
end;
if not(error) then
begin
data.Clear;
data.Add('s='+Copy(PageProfile, Pos('value', PageProfile)+7, 56));
data.Add('op=slogin');
data.Add('redirect=1');
data.Add('expire=0');
data.Add('to=');
IdHTTP1.HandleRedirects:=true;
try
PageProfile:=IdHTTP1.Post('http://vk.com/login.php', data);
except
end;
beginpos := Pos('center', PageProfile);
endpos := PosEx('/>', PageProfile, beginpos + 21); // PosEx тут подчеркнуто красным.
pic := Copy(PageProfile, beginpos + 21, endpos - (beginpos + 21));
ShowMessage(pic);
ms := TMemoryStream.Create;
jpeg := TJpegImage.Create;
try
IdHTTP1.Get(pic, ms);
ms.Position := 0;
jpeg.LoadFromStream(ms);
Image1.Picture.Graphic := jpeg;
finally
jpeg.Free; ms.Free;
end;
end
else
ShowMessage('Авторизация не удалась');
Data.Free;
end;
end.