unigui图形验证码

unigui图形验证码

procedure TMainForm.UniButton1Click(Sender: TObject);
var
  url: SockString;
  serial: TynSerial;
  i: Integer;
  ms: TMemoryStream;
begin
  serial := TynSerial.Create;
  ms := TMemoryStream.Create;
  try
    url := 'verifycode';
    i := FHttp.Post(url, '', 'text/plain; charset=UTF-8');
    if i = 200 then
    begin
      serial.Text := FHttp.Content;
      UniEdit1.Text := serial.ReadString('code');
      serial.ReadStream('image', ms);
      ms.Position := 0;
      UniImage1.LoadFromStream(ms);
    end
    else
      ShowMessage(i.ToString + ' error');
  finally
    serial.Free;
    ms.Free;
  end;
end;

  

posted @ 2019-05-18 09:04  delphi中间件  阅读(1440)  评论(0编辑  收藏  举报