本文作者:qiaoqingyi

delphi7编程实例(编程 delphi)

qiaoqingyi 05-30 110

  Delphi是美国Borland(宝兰)公司开发的工作在Windows平台下的开发工具,它的前身是在DOS下的产品Borland Turbo Pascal。从产品名称上就可以知道,Turbo Pascal使用的是Pascal语言。从Turbo Pascal 5.5版本开始,Borland公司在传统Pascal的基础上加入了面向对象的功能。

  DelphiXE|Delphi7短信验证码接口发送DEMO

  其他语言接口下载(完整版):https://www.bonzson.net/page.php?cid=1482

  以下是部分代码片段:

  program SendSmsDemo;

  uses

  Forms,

  frmMainUnit in 'frmMainUnit.pas' {frmMain};

  {$R *.res}

  begin

  Application.Initialize;

  Application.Title := 'SendSmsDemo';

  Application.CreateForm(TfrmMain, frmMain);

  Application.Run;

  end.

  以下是Delphi7代码片段:

  unit frmMainUnit;

  interface

  uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,

  IdHTTP, StdCtrls, ComCtrls;

  type

  TfrmMain = class(TForm)

  Button1: TButton;

  Button2: TButton;

  Button3: TButton;

  CheckBox1: TCheckBox;

  DateTimePicker1: TDateTimePicker;

  DateTimePicker2: TDateTimePicker;

  Label1: TLabel;

  Label2: TLabel;

  Memo1: TMemo;

  Edit1: TEdit;

  Label3: TLabel;

  Edit2: TEdit;

  Label4: TLabel;

  IdHTTP1: TIdHTTP;

  StaticText1: TStaticText;

  procedure Button1Click(Sender: TObject);

  procedure Button2Click(Sender: TObject);

  procedure Button3Click(Sender: TObject);

  procedure FormCreate(Sender: TObject);

  private

  { Private declarations }

  public

  { Public declarations }

  end;

  var

  frmMain : TfrmMain;

  implementation

  {$R *.dfm}

  uses httpapp;

  procedure TfrmMain.Button1Click(Sender: TObject);

  var

  vParam : TStringList;

  begin //验证帐号

  vParam := TStringList.Create;

  try

  vParam.Add('id=test');

  vParam.Add('pwd=test');

  vParam.Add('cmd=1');

  IdHTTP1.Request.AcceptCharSet := 'utf8';

  IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';

  Edit2.Text := IdHTTP1.Post('https://ls5588.vicp.cc:8090', vParam);

  finally

  vParam.Free;

  end;

  end;

  procedure TfrmMain.Button2Click(Sender: TObject);

  var

  vParam : TStringList;

  begin //查询余额

  vParam := TStringList.Create;

  try

  vParam.Add('id=test');

delphi7编程实例(编程 delphi)

  vParam.Add('pwd=test');

  vParam.Add('cmd=2');

  IdHTTP1.Request.AcceptCharSet := 'utf8';

  IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';

  Edit2.Text := IdHTTP1.Post('https://ls5588.vicp.cc:8090', vParam);

  finally

  vParam.Free;

  end;

  end;

  procedure TfrmMain.Button3Click(Sender: TObject);

  var

  vParam : TStringList;

  begin //发送短信

  vParam := TStringList.Create;

  try

  vParam.Add('id=test');

  vParam.Add('pwd=test');

  vParam.Add('content=' + HTTPEncode(Memo1.Lines.Text));

  vParam.Add('mobile=' + HTTPEncode(Edit1.Text));

  if CheckBox1.Checked then

  begin

  vParam.Add('sendtime='

  + formatdatetime('yyyyMMdd', DateTimePicker1.Date)

  + formatdatetime('HHmmss', DateTimePicker2.Time));

  end

  else

  vParam.Add('sendtime=0');

  IdHTTP1.Request.AcceptCharSet := 'utf8';

  IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';

  Edit2.Text := IdHTTP1.Post('https://ls5588.vicp.cc:8090', vParam);

  finally

  vParam.Free;

  end;

  end;

  procedure TfrmMain.FormCreate(Sender: TObject);

  begin

  DateTimePicker1.DateTime := now;

  DateTimePicker2.DateTime := now;

  end;

  end.

阅读
分享