冬
冬月
Unregistered / Unconfirmed
GUEST, unregistred user!
就这么些代码在D7里始终是unable to create process,重启,换了机器也是这样,请教高手unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, StdCtrls, ExtCtrls, StrUtils, IdHashMessageDigest, IdHash, Jpeg;type TForm1 = class(TForm) Image1: TImage
LoginBtn: TButton
Button1: TButton
Edit1: TEdit
UserEdt: TEdit
PwsEdt: TEdit
VerifyPicEdt: TEdit
Memo1: TMemo
IdHTTP1: TIdHTTP
procedure FormShow(Sender: TObject)
procedure LoginBtnClick(Sender: TObject)
private { Private declarations } public { Public declarations } end;var Form1: TForm1
QQ_Cookie, VerifySession:String;implementation{$R *.dfm}//提取字符串function SubString(aInputStr, aStr_L, aStr_R:string):string;var sPosB,sPosE:integer
Lwhtml,LwCstr_L,LwCstr_R:string;begin Result:=''
if Trim(aInputStr)='' then Exit
Lwhtml:= LowerCase(aInputStr)
LwCstr_L := LowerCase(aStr_L)
LwCstr_R := LowerCase(aStr_R)
sPosB:= Pos(LwCstr_L, Lwhtml) + Length(LwCstr_L)
sPosE:= PosEx(LwCstr_R, Lwhtml, sPosB)
if (sPosB<sPosE) and (sPosE>0) then Result:=Copy(aInputStr, sPosB, sPosE-sPosB);end;function HashStr2BinStr(Hash:string):string;var buf:array[0..63] of Char
i:Integer;begin Result:=''
FillChar(buf,SizeOf(buf),0)
SetLength(Result,Round(Length(Hash)/2))
FillChar(Result[1],Length(Result),0)
HexToBin(PChar(Hash),buf,SizeOf(buf))
for i:=0 to Round(Length(Hash)/2)-1 do Result[i+1]:=buf
end;function Fmd5(str:string):string;var md5 : TIdHashMessageDigest5
longWordRec : T4x4LongWordRecord;begin md5 := TIdHashMessageDigest5.Create
try {$IFDEF ID10} Result:=md5.HashStringAsHex(str)
{$ELSE} longWordRec:=md5.HashValue(str)
Result:=md5.AsHex(longWordRec)
{$ENDIF} finally md5.Free
end
end;function md5_3(str:string):string;begin Result:=Fmd5(str)
Result:=HashStr2BinStr(Result)
Result:=Fmd5(Result)
Result:=HashStr2BinStr(Result)
Result:=Fmd5(Result);end;function preprocess(pass,verifycode:string):string;begin Result:=Fmd5(md5_3(pass)+UpperCase(verifycode));end;procedure TForm1.FormShow(Sender: TObject);var ms:TMemoryStream
pic:TJPEGImage;begin ms:=TMemoryStream.Create
IdHTTP1.Request.SetHeaders
IdHTTP1.Request.RawHeaders.Clear
IdHTTP1.Request.Accept:='*/*'
IdHTTP1.Request.AcceptEncoding:='gzip, deflate'
IdHTTP1.Request.AcceptLanguage:='zh-cn'
//IdHTTP1.Request.CacheControl:='no-cache'
IdHTTP1.Request.Connection:='Keep-Alive'
//IdHTTP1.Request.ContentLength:=209
//IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded'
IdHTTP1.Request.Host:='ptlogin2.qq.com'
//IdHTTP1.Request.Referer:='http://ui.ptlogin2.qq.com/cgi-bin/login?link_target=blank&appid=15000101&s_url=http%3A//php.qzone.qq.com/index.php%3Fmod%3Dportal%26act%3Dlogin&f_url=loginerroralert&target=top&qlogin_jumpname=jump&qlogin_param=u1%3Dhttp%3A//php.qzone.qq.com/index.php%3Fmod%3Dportal%26act%3Dlogin'
IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible
MSIE 7.0
Windows NT 5.1
Trident/4.0
.NET CLR 2.0.50727
.NET CLR 3.0.4506.2152
.NET CLR 3.5.30729)'
IdHTTP1.Request.Host:='ui.ptlogin2.qq.com'
IdHTTP1.Get(Format('http://ptlogin2.qq.com/getimage?aid=15000101&%0.16f', [Time()]) , ms)
ms.Position:=0
pic:=TJPEGImage.Create
try pic.LoadFromStream(ms)
Image1.Picture.Assign(pic)
finally pic.Free
ms.Free
end
QQ_Cookie:= ''
QQ_Cookie:= SubString(IdHTTP1.Response.RawHeaders.Text, 'Set-Cookie: verifysession=', ';')
memo1.Lines.Add(QQ_Cookie)
memo1.Lines.Add('******************************')
QQ_Cookie:= 'verifysession=' + QQ_Cookie + ';'
memo1.Lines.Add(QQ_Cookie)
memo1.Lines.Add('******************************')
VerifySession:= QQ_Cookie
//IdHTTP1.Request.CustomHeaders.Clear
//IdHTTP1.Request.CustomHeaders.Add('Cookie:'+QQ_Cookie);end;procedure TForm1.LoginBtnClick(Sender: TObject);var Params:TStrings
url,tmp:String;begin Params :=TStringList.Create
try Params.Append('aid=15000101')
Params.Append('dumy=')
//???? Params.Append('fp=loginerroralert')
Params.Append('from_ui=1')
Params.Append('h=1')
Params.Append('p='+preprocess(PwsEdt.Text,VerifyPicEdt.Text));//密码和校验码MD5值 Params.Append('ptlang=0')
Params.Append('ptredirect=1')
Params.Append('u='+UserEdt.Text);//QQ号码 Params.Append('u1=http://php.qzone.qq.com/index.php?mod=portal&act=login')
Params.Append('verifycode='+VerifyPicEdt.Text);//校验码 try url := 'http://ptlogin2.qq.com/login'
IdHTTP1.HandleRedirects:=False
idhttp1.Post(url,Params)
//tmp:=idhttp1.Post(url,Params)
except end
finally Params.Free
end
Memo1.Lines.Add(tmp);end;end.
LoginBtn: TButton
Button1: TButton
Edit1: TEdit
UserEdt: TEdit
PwsEdt: TEdit
VerifyPicEdt: TEdit
Memo1: TMemo
IdHTTP1: TIdHTTP
procedure FormShow(Sender: TObject)
procedure LoginBtnClick(Sender: TObject)
private { Private declarations } public { Public declarations } end;var Form1: TForm1
QQ_Cookie, VerifySession:String;implementation{$R *.dfm}//提取字符串function SubString(aInputStr, aStr_L, aStr_R:string):string;var sPosB,sPosE:integer
Lwhtml,LwCstr_L,LwCstr_R:string;begin Result:=''
if Trim(aInputStr)='' then Exit
Lwhtml:= LowerCase(aInputStr)
LwCstr_L := LowerCase(aStr_L)
LwCstr_R := LowerCase(aStr_R)
sPosB:= Pos(LwCstr_L, Lwhtml) + Length(LwCstr_L)
sPosE:= PosEx(LwCstr_R, Lwhtml, sPosB)
if (sPosB<sPosE) and (sPosE>0) then Result:=Copy(aInputStr, sPosB, sPosE-sPosB);end;function HashStr2BinStr(Hash:string):string;var buf:array[0..63] of Char
i:Integer;begin Result:=''
FillChar(buf,SizeOf(buf),0)
SetLength(Result,Round(Length(Hash)/2))
FillChar(Result[1],Length(Result),0)
HexToBin(PChar(Hash),buf,SizeOf(buf))
for i:=0 to Round(Length(Hash)/2)-1 do Result[i+1]:=buf
end;function Fmd5(str:string):string;var md5 : TIdHashMessageDigest5
longWordRec : T4x4LongWordRecord;begin md5 := TIdHashMessageDigest5.Create
try {$IFDEF ID10} Result:=md5.HashStringAsHex(str)
{$ELSE} longWordRec:=md5.HashValue(str)
Result:=md5.AsHex(longWordRec)
{$ENDIF} finally md5.Free
end
end;function md5_3(str:string):string;begin Result:=Fmd5(str)
Result:=HashStr2BinStr(Result)
Result:=Fmd5(Result)
Result:=HashStr2BinStr(Result)
Result:=Fmd5(Result);end;function preprocess(pass,verifycode:string):string;begin Result:=Fmd5(md5_3(pass)+UpperCase(verifycode));end;procedure TForm1.FormShow(Sender: TObject);var ms:TMemoryStream
pic:TJPEGImage;begin ms:=TMemoryStream.Create
IdHTTP1.Request.SetHeaders
IdHTTP1.Request.RawHeaders.Clear
IdHTTP1.Request.Accept:='*/*'
IdHTTP1.Request.AcceptEncoding:='gzip, deflate'
IdHTTP1.Request.AcceptLanguage:='zh-cn'
//IdHTTP1.Request.CacheControl:='no-cache'
IdHTTP1.Request.Connection:='Keep-Alive'
//IdHTTP1.Request.ContentLength:=209
//IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded'
IdHTTP1.Request.Host:='ptlogin2.qq.com'
//IdHTTP1.Request.Referer:='http://ui.ptlogin2.qq.com/cgi-bin/login?link_target=blank&appid=15000101&s_url=http%3A//php.qzone.qq.com/index.php%3Fmod%3Dportal%26act%3Dlogin&f_url=loginerroralert&target=top&qlogin_jumpname=jump&qlogin_param=u1%3Dhttp%3A//php.qzone.qq.com/index.php%3Fmod%3Dportal%26act%3Dlogin'
IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible
MSIE 7.0
Windows NT 5.1
Trident/4.0
.NET CLR 2.0.50727
.NET CLR 3.0.4506.2152
.NET CLR 3.5.30729)'
IdHTTP1.Request.Host:='ui.ptlogin2.qq.com'
IdHTTP1.Get(Format('http://ptlogin2.qq.com/getimage?aid=15000101&%0.16f', [Time()]) , ms)
ms.Position:=0
pic:=TJPEGImage.Create
try pic.LoadFromStream(ms)
Image1.Picture.Assign(pic)
finally pic.Free
ms.Free
end
QQ_Cookie:= ''
QQ_Cookie:= SubString(IdHTTP1.Response.RawHeaders.Text, 'Set-Cookie: verifysession=', ';')
memo1.Lines.Add(QQ_Cookie)
memo1.Lines.Add('******************************')
QQ_Cookie:= 'verifysession=' + QQ_Cookie + ';'
memo1.Lines.Add(QQ_Cookie)
memo1.Lines.Add('******************************')
VerifySession:= QQ_Cookie
//IdHTTP1.Request.CustomHeaders.Clear
//IdHTTP1.Request.CustomHeaders.Add('Cookie:'+QQ_Cookie);end;procedure TForm1.LoginBtnClick(Sender: TObject);var Params:TStrings
url,tmp:String;begin Params :=TStringList.Create
try Params.Append('aid=15000101')
Params.Append('dumy=')
//???? Params.Append('fp=loginerroralert')
Params.Append('from_ui=1')
Params.Append('h=1')
Params.Append('p='+preprocess(PwsEdt.Text,VerifyPicEdt.Text));//密码和校验码MD5值 Params.Append('ptlang=0')
Params.Append('ptredirect=1')
Params.Append('u='+UserEdt.Text);//QQ号码 Params.Append('u1=http://php.qzone.qq.com/index.php?mod=portal&act=login')
Params.Append('verifycode='+VerifyPicEdt.Text);//校验码 try url := 'http://ptlogin2.qq.com/login'
IdHTTP1.HandleRedirects:=False
idhttp1.Post(url,Params)
//tmp:=idhttp1.Post(url,Params)
except end
finally Params.Free
end
Memo1.Lines.Add(tmp);end;end.