奇怪的就是在我的电脑上运行就没问题,在别人的机器上用的话就是连接不上网络,不知道是不是发布有问题,还是发布的时候需要带什么DLL,还有就是别人在局域网中测试也连接不上,而我在局域网测试,一点问题也没有,真的不知道该怎么解决了!
代码如下:
var
a, b: string;
name: string;
newurl: string;
password: string;
typeee: string;
GetURL: string;
PostURL: string;
GetHtml: string;
sParams, typee: string;
aParams: TStrings;
list: TStringList;
aStream: TStringStream;
begin
try
IdHTTP1 := TIdHTTP.Create(nil);
aParams := TStringList.Create;
aStream := TStringStream.Create('');
name := trim(namee.Text);
password := trim(pwdd.Text);
typeee := '1'; //1为企业,2行政部门,3检查中心
GetURL := 'http://tzzf.51ton.com/client/CheckUser.aspx'; {登录页面网址}
PostURL :='http://tzzf.51ton.com/client/CheckUser.aspx?username=' + name; {提交网址}
sParams := 'password=' + password; {提交参数}
typee := 'type=' + typeee;
try
list := TStringList.Create;
aParams.Clear;
aParams.Add(sParams);
aParams.Add(typee);
GetHtml := IdHTTP1.Get(GetURL); {取登录页面}
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Post(PostURL, aParams, aStream); {提交}
list.Delimiter := ',';
list.DelimitedText := aStream.DataString;
if (list.Count = 1) then
begin
a := list[0];
end
else begin //-2登陆失败
a := list[0]; //是否更新1为更新,-1为不更新
b := list[1]; //返回网址
end;
if (StrToInt(list[0]) = -2) then
begin
timer1.Enabled:=false;
application.MessageBox('您输入的用户名或密码错误!', '提示', 64);
close;
end
else begin
if (StrToInt(list[0]) <> -1) then
begin
application.CreateForm(tform1, form1);
self.N1.Enabled := true;
newurl := 'http://tzzf.51ton.com/client/newlist.htm?u=' + name + '&p=' + password + '&utype=1';
form1.WebBrowser1.Navigate(newurl);
form1.Show;
end;
end;
finally
IdHTTP1.Free;
aParams.Free;
aStream.Free;
end;
except
timer1.Enabled:=false;
application.MessageBox('网络连接错误!', '提示', 64);
Form2.close;
end;
end;
代码如下:
var
a, b: string;
name: string;
newurl: string;
password: string;
typeee: string;
GetURL: string;
PostURL: string;
GetHtml: string;
sParams, typee: string;
aParams: TStrings;
list: TStringList;
aStream: TStringStream;
begin
try
IdHTTP1 := TIdHTTP.Create(nil);
aParams := TStringList.Create;
aStream := TStringStream.Create('');
name := trim(namee.Text);
password := trim(pwdd.Text);
typeee := '1'; //1为企业,2行政部门,3检查中心
GetURL := 'http://tzzf.51ton.com/client/CheckUser.aspx'; {登录页面网址}
PostURL :='http://tzzf.51ton.com/client/CheckUser.aspx?username=' + name; {提交网址}
sParams := 'password=' + password; {提交参数}
typee := 'type=' + typeee;
try
list := TStringList.Create;
aParams.Clear;
aParams.Add(sParams);
aParams.Add(typee);
GetHtml := IdHTTP1.Get(GetURL); {取登录页面}
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Post(PostURL, aParams, aStream); {提交}
list.Delimiter := ',';
list.DelimitedText := aStream.DataString;
if (list.Count = 1) then
begin
a := list[0];
end
else begin //-2登陆失败
a := list[0]; //是否更新1为更新,-1为不更新
b := list[1]; //返回网址
end;
if (StrToInt(list[0]) = -2) then
begin
timer1.Enabled:=false;
application.MessageBox('您输入的用户名或密码错误!', '提示', 64);
close;
end
else begin
if (StrToInt(list[0]) <> -1) then
begin
application.CreateForm(tform1, form1);
self.N1.Enabled := true;
newurl := 'http://tzzf.51ton.com/client/newlist.htm?u=' + name + '&p=' + password + '&utype=1';
form1.WebBrowser1.Navigate(newurl);
form1.Show;
end;
end;
finally
IdHTTP1.Free;
aParams.Free;
aStream.Free;
end;
except
timer1.Enabled:=false;
application.MessageBox('网络连接错误!', '提示', 64);
Form2.close;
end;
end;
你的是NAT转换的局域网,就能直接上