как правельно доделать программу проверки баланса ан antigate ?

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by kakeolala, 27 Sep 2010.

  1. kakeolala

    kakeolala Banned

    Joined:
    13 Jul 2010
    Messages:
    118
    Likes Received:
    2
    Reputations:
    0
    Вот тут что смо - то написал:
    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
      IdTCPClient, IdHTTP, Menus, ComCtrls;
    
    type
      TForm1 = class(TForm)
        http: TIdHTTP;
        Button1: TButton;
        MainMenu1: TMainMenu;
        OpenDialog1: TOpenDialog;
        N1: TMenuItem;
        N2: TMenuItem;
        ListView1: TListView;
        procedure N2Click(Sender: TObject);
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        procedure antigate(key:string;i:integer);
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
      list:tstringlist;i:integer;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.antigate(key:string;i:integer);
    var a:string;li: TListItem;
    begin
     a := http.get('http://antigate.com/res.php?key='+key+'&action=getbalance');
     ListView1.Items.Item[i].SubItems.Add(a);
    end;
    
    procedure TForm1.N2Click(Sender: TObject);
    var li: TListItem;
    begin
     list:=tstringlist.Create;
     if opendialog1.Execute then list.LoadFromFile(opendialog1.FileName);
     for i:=0 to list.Count-1 do
      begin
       ListView1.Items.Add.Caption:='';
       ListView1.Items.Add.SubItems.Add('');
       ListView1.Items.Item[i].Caption:= list[i];
      end; 
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
     for i:=0 to list.Count-1 do antigate(list[i],i);
    end;
    
    end.
    не имею понятия о том как сделать чтобы бралась инфа о балансе без зависаний и вылетов(((((((((
     
  2. RedFern.89

    RedFern.89 Member

    Joined:
    20 Jan 2010
    Messages:
    557
    Likes Received:
    45
    Reputations:
    0
    ну как то так

    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
      IdTCPClient, IdHTTP, Menus, ComCtrls;
    
    type
      TForm1 = class(TForm)
        http: TIdHTTP;
        Button1: TButton;
        MainMenu1: TMainMenu;
        OpenDialog1: TOpenDialog;
        N1: TMenuItem;
        N2: TMenuItem;
        ListView1: TListView;
        procedure N2Click(Sender: TObject);
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        procedure antigate(key:string;i:integer);
        { Public declarations }
      end;
    
    type
      Tcheck = class(TThread)
      key:string;
      i : Integer;
      procedure Execute; override;
    end;
    
    var
      Form1: TForm1;
      list:tstringlist;i:integer;
    
    implementation
    
    {$R *.dfm}
    
    procedure TCheck.Execute;
    begin
     a := http.get('http://antigate.com/res.php?key='+key+'&action=getbalance');
     ListView1.Items.Item[i].SubItems.Add(a);
    end;
    
    procedure TForm1.N2Click(Sender: TObject);
    var li: TListItem;
    begin
     list:=tstringlist.Create;
     if opendialog1.Execute then list.LoadFromFile(opendialog1.FileName);
     for i:=0 to list.Count-1 do
      begin
       ListView1.Items.Add.Caption:='';
       ListView1.Items.Add.SubItems.Add('');
       ListView1.Items.Item[i].Caption:= list[i];
      end; 
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var check : TCheck;
    begin
     for i:=0 to list.Count-1 do 
     begin
      Check := TChec.Create(true);
      Check.Key := list[i];
      check.i := i;
      check.Resume;
      Check.Free;
     end;
    end;
    
    end.
    
     
    #2 RedFern.89, 27 Sep 2010
    Last edited: 27 Sep 2010