6 Star 10 Fork 6

itlabers / delphi4wechat

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backend.pas 3.02 KB
一键复制 编辑 原始数据 按行查看 历史
itlabers 提交于 2016-06-06 20:45 . first commit
unit backend;
interface
uses
Classes;
type
LoginThread = class(TThread)
private
returnMessage:string;
protected
procedure Execute; override;
procedure notice;
end;
implementation
uses webapp,main,jpeg,sysutils;
procedure LoginThread.Execute;
var flag:boolean;
jpg:TJpegImage;
wxWeb: TWxWeb;
sucess:boolean;
begin
// flag:=false;
wxWeb:=TWxWeb.Create;
jpg:=TJpegImage.Create;
sucess:=wxWeb.getUUID();
if sucess <> true then
begin
returnMessage:='获取UUID失败';
synchronize(notice);
exit;
end;
sucess:=wxWeb.showQRImage();
if sucess <> true then
begin
returnMessage:='获取二维码失败';
synchronize(notice);
exit;
end;
wxWeb.imagestream.Position:=0;
jpg.LoadFromStream(wxWeb.imagestream);
Form1.image1.Picture.Assign(jpg);
sleep(3000);
repeat
returnMessage:='等待登陆';
flag:= wxWeb.waitForLogin();
if flag = true then
begin
break;
end
until (flag);
sucess:= wxWeb.login();
if sucess <> true then
begin
returnMessage:=' 登陆失败';
synchronize(notice);
exit;
end;
sucess:=wxWeb.wxInit();
if sucess <> true then
begin
returnMessage:=' 初始化微信失败';
synchronize(notice);
exit;
end;
sucess:= wxWeb.wxStatusNotify();
if sucess <> true then
begin
returnMessage:='开启信息通知失败';
synchronize(notice);
exit;
end;
sucess:= wxWeb.wxgetContact();
if sucess <> true then
begin
returnMessage:='获取联系人失败';
synchronize(notice);
exit;
end;
returnMessage:='联系人总数:'+inttoStr(wxweb.MemberCount);
synchronize(notice);
while not Terminated do
begin
sleep(500);
sucess:= wxWeb.syncMessageCheck() ;
returnMessage:=' 信息检测 retcode:='+wxWeb.retcode+' retcode:='+wxWeb.selector;
synchronize(notice);
if sucess <> true then
begin
returnMessage:=' 轮训信息失败 retcode:='+wxWeb.retcode+' selector:='+wxWeb.selector;
synchronize(notice);
if (wxWeb.retcode = '1101') or (wxWeb.retcode= '1100') then
break;
end;
sucess:=wxWeb.syncMessageGet();
if sucess <> true then
begin
returnMessage:=' 获取消息失败';
synchronize(notice);
end;
continue;
end;
{ Place thread code here }
end;
procedure LoginThread.notice();
begin
Form1.Memo1.Lines.Add(returnMessage);
end;
end.
Delphi
1
https://gitee.com/spirit_demon/delphi4wechat.git
git@gitee.com:spirit_demon/delphi4wechat.git
spirit_demon
delphi4wechat
delphi4wechat
master

搜索帮助