如何在程序里实现手机短信的发送???(100分)

  • 主题发起人 主题发起人 颜夕真
  • 开始时间 开始时间

颜夕真

Unregistered / Unconfirmed
GUEST, unregistred user!
谢谢了,最好由例子
 
客户端还是服务器端??
 
就是发送短信给别人,
 
得看你短信网关的协议
 
我有原程序 请留下邮件
 
yanxizhen@hotmail.com,谢谢!
 
119.
老大我也要啊
sarny_12@163.net
 
to 119:
来一封,谢谢,lxt@lztx.com
 
TO 119:
也给我一份可以吗??MIANL@21CN.COM
 
可以给我一份吗?xxz_lyl@21cn.com。THANK YOU!!!
 
也给我一份好吗
chenyscar0036@sina.com
 
例子?DELPHI里DEMO下的FASTNET下的NMHTTP例程序的
POST 和 GET功能 就这两个就行了 不过要依赖别人的
服务器啦
 
大家谁得到了给我一个?我觉得老是麻烦119怪不好意思的。先谢谢119了
 
能不能给我一份研究一下:zyz_nj@21cn.com
 
TO 119:
也给我一份可以吗?yanghai0437@sina.com
 
unit smsform;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, TFlatColorComboBoxUnit, TFlatComboBoxUnit,
ComCtrls, ExtCtrls, XP_CheckBox, OleCtrls, SHDocVw, Grids, TFlatPanelUnit,
TFlatMemoUnit,inifiles,shellapi;

type
Tsmsfrm = class(TForm)
SpeedButton1: TSpeedButton;
GroupBox2: TGroupBox;
Label3: TLabel;
myphonebook: TFlatComboBox;
Label4: TLabel;
memomsg: TMemo;
btnsend: TSpeedButton;
Panel1: TPanel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label1: TLabel;
Label2: TLabel;
mypwd: TEdit;
mycode: TFlatComboBox;
btntimesend: TSpeedButton;
Shape1: TShape;
Shape2: TShape;
Panel2: TPanel;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
CheckBox1: TXP_CheckBox;
TabSheet3: TTabSheet;
Web: TWebBrowser;
Edit1: TEdit;
Panel3: TPanel;
tv: TTreeView;
sp: TSplitter;
sg: TStringGrid;
memosms: TFlatPanel;
Label10: TLabel;
Panel4: TPanel;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
GroupBox1: TGroupBox;
edtname: TLabeledEdit;
Label11: TLabel;
rb1: TRadioButton;
rb2: TRadioButton;
edtphone: TLabeledEdit;
Label12: TLabel;
Memo1: TMemo;
sg2: TStringGrid;
frendcode: TFlatComboBox;
Shape4: TShape;
Shape3: TShape;
Shape5: TShape;
Shape6: TShape;
Shape7: TShape;
Shape8: TShape;
Shape9: TShape;
Shape10: TShape;
Shape11: TShape;
Shape12: TShape;
Shape13: TShape;
Shape14: TShape;
Label13: TLabel;
procedure SpeedButton1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure PageControl1Change(Sender: TObject);
procedure WebDocumentComplete(Sender: TObject; const pDisp: IDispatch;
var URL: OleVariant);
procedure FormCreate(Sender: TObject);
procedure btnsendClick(Sender: TObject);
procedure WebBeforeNavigate2(Sender: TObject; const pDisp: IDispatch;
var URL, Flags, TargetFrameName, PostData, Headers: OleVariant;
var Cancel: WordBool);
procedure mycodeClick(Sender: TObject);
procedure mypwdClick(Sender: TObject);
procedure frendcodeClick(Sender: TObject);
procedure memomsgChange(Sender: TObject);
procedure spMoved(Sender: TObject);
procedure tvClick(Sender: TObject);
procedure sgMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure tvMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure sgDblClick(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure sg2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure SpeedButton4Click(Sender: TObject);
procedure sg2Click(Sender: TObject);
procedure myphonebookChange(Sender: TObject);
procedure edtnameKeyPress(Sender: TObject; var Key: Char);
procedure edtphoneKeyPress(Sender: TObject; var Key: Char);
procedure SpeedButton3Click(Sender: TObject);
procedure sg2DblClick(Sender: TObject);
procedure Shape10MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure btntimesendClick(Sender: TObject);
procedure Label13Click(Sender: TObject);
procedure memomsgKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;

var
smsfrm: Tsmsfrm;
c,r:integer;
cr,cr1:integer;
url:string;
implementation
uses smsdll, loginform, modiform, regform;
{$R *.dfm}

procedure Tsmsfrm.SpeedButton1Click(Sender: TObject);
begin
close;
end;

procedure Tsmsfrm.FormActivate(Sender: TObject);
begin
myphonebook.Enabled := checkbox1.Checked;
tv.OnMouseMove(sender,[ssleft],0,0);
pagecontrol1.ActivePageIndex :=0;
tv.Items[1].Selected :=true;
tv.OnClick(sender);
mycode.Text :=curuser.phone;
end;

procedure Tsmsfrm.CheckBox1Click(Sender: TObject);
begin
myphonebook.Enabled :=checkbox1.Checked;
end;

procedure Tsmsfrm.PageControl1Change(Sender: TObject);
begin
edit1.Visible :=( pagecontrol1.ActivePageIndex=2);
end;

procedure Tsmsfrm.WebDocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
i,j,ok:integer;
doc:olevariant;
begin
ok:=0;
doc:=(sender as twebbrowser).document;
j:=doc.all.length;
for i:=0 to j-1 do
begin
if (doc.all.item(i).tagname='INPUT')or
(doc.all.item(i).tagname='TEXTAREA') then
begin
if (doc.all.item(i).tagname='INPUT')and
(doc.all.item(i).type='text')and
(doc.all.item(i).name='phone') then //对方手机号
begin
inc(ok); //=1
doc.all.item(i).value:=frendcode.Text;
end;
if(doc.all.item(i).tagname='TEXTAREA')and
(doc.all.item(i).name='content') then//内容
begin
inc(ok); //=2
doc.all.item(i).value:=memomsg.Text;
end;
if (doc.all.item(i).tagname='INPUT')and
(doc.all.item(i).type='text')and
(doc.all.item(i).name='mycode') then //我的手机号
begin
inc(ok);//=3
doc.all.item(i).value:=mycode.Text;
end;
if (doc.all.item(i).tagname='INPUT')and
(doc.all.item(i).type='password') and
(doc.all.item(i).name='mypw') then //密码
begin
inc(ok); //=4
doc.all.item(i).value:=mypwd.Text;
end;
if (doc.all.item(i).tagname='INPUT')and
(doc.all.item(i).type='submit')and
(doc.all.item(i).value=' 发送 ') then //发送按钮
begin
inc(ok);//=5
if ok=7 then
doc.all.item(i).click;
end;
end;
end;
end;

procedure Tsmsfrm.FormCreate(Sender: TObject);
begin
loginfrm.showmodal;
r:=0;
url:='www.smschina.com';
sg.Cells[0,0]:='编号';
sg.Cells[1,0]:='内容';
sg.Cells[2,0]:='人气';
sg2.Cells[0,0]:='编号';
sg2.Cells[1,0]:='姓名';
sg2.Cells[2,0]:='性别';
sg2.Cells[3,0]:='手机号';
sg2.Cells[4,0]:='备注';
ini:=tinifile.create(extractfilepath(application.exename)+curuser.phone +'.ini');
readini;
updatephone;
// showmessage(inttostr(length(label10.Caption)));
end;

procedure Tsmsfrm.btnsendClick(Sender: TObject);
var
i1,i2,i3,i4:olevariant;
begin
if length(trim(mycode.Text))<>11 then
begin
messagebox(handle,'请输入您的手机号码。','警告',mb_ok or mb_iconwarning);
mycode.SetFocus;
mycode.SelectAll;
exit;
end;
if trim(mypwd.Text)='' then
begin
messagebox(handle,'请输入您的手机密码。','警告',mb_ok or mb_iconwarning);
mypwd.SetFocus;
mypwd.SelectAll;
exit;
end;
if length(trim(frendcode.Text))<>11 then
begin
messagebox(handle,'请输入对方的手机号码。','警告',mb_ok or mb_iconwarning);
frendcode.SetFocus;
frendcode.SelectAll;
exit;
end;
if trim( memomsg.Text)='' then
begin
messagebox(handle,'不能发送空消息。','警告',mb_ok or mb_iconwarning);
memomsg.SetFocus;
memomsg.SelectAll;
exit;
end;
i1:=0;
i2:=0;
i3:=0;
i4:=0;
web.Navigate(url,i1,i2,i3,i4);
pagecontrol1.ActivePageIndex :=2;
pagecontrol1.OnChange(sender);
end;

procedure Tsmsfrm.WebBeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
edit1.Text :=url;
end;

procedure Tsmsfrm.mycodeClick(Sender: TObject);
begin
mycode.SelectAll ;
end;

procedure Tsmsfrm.mypwdClick(Sender: TObject);
begin
mypwd.SelectAll;
end;

procedure Tsmsfrm.frendcodeClick(Sender: TObject);
begin
frendcode.SelectAll;
end;

procedure Tsmsfrm.memomsgChange(Sender: TObject);
var
i:integer;
j:integer;
begin
j:=0;
for i:=1 to length(trim(memomsg.Text)) do
begin
if bytetype(trim(memomsg.Text),i-1)<>mbleadbyte then
inc(j);
end;
label8.Caption :=inttostr(j);
end;

procedure Tsmsfrm.spMoved(Sender: TObject);
begin
tv.Width :=sp.Left;
sg.Left:=sp.Left +sp.Width;
sg.Width :=panel3.Width -sp.Width -tv.Width-1;
end;

procedure Tsmsfrm.tvClick(Sender: TObject);
var
st:ttreenode;
begin
st:=nil;
if tv.Selected =nil then exit;
if tv.Selected <>nil then
st:=tv.Selected;
if (st=tv.Items[0])or(st=tv.Items[2]) then
exit;
sg.RowCount :=2;
sg.Cells[0,1]:='';
sg.Cells[1,1]:='';
sg.Cells[2,1]:='';
if (st=tv.Items[1])and(fileexists('sms1.txt')) then
updatesg('sms1.txt');
if (st=tv.Items[3])and(fileexists('sms3.txt')) then
updatesg('sms3.txt');
if (st=tv.Items[4]) and(fileexists('sms4.txt'))then
updatesg('sms4.txt');
if (st=tv.Items[5])and(fileexists('sms5.txt')) then
updatesg('sms5.txt');
if (st=tv.Items[6])and(fileexists('sms6.txt')) then
updatesg('sms6.txt');

end;

procedure Tsmsfrm.sgMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
k:integer;
begin
sg.MouseToCell(x,y,c,r);
if r>0 then
begin
label10.Caption :=' '+sg.Cells[1,r];
k:=length(label10.Caption);
k:=((k-1) div 48)+1;
k:=k*18;
label10.Height :=k;
memosms.Height :=k+12;
if trim(label10.Caption) <>'' then
memosms.Visible :=true;
memosms.Top :=y+54;
end
else
memosms.Visible :=false;
end;

procedure Tsmsfrm.tvMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
i:integer;
begin
memosms.Visible :=false;
shape3.Pen.Color :=bkcolor;
shape4.Pen.Color :=bkcolor;
shape5.Pen.Color :=bkcolor;
shape6.Pen.Color :=bkcolor;
shape7.Pen.Color:=bkcolor;
shape8.Pen.Color :=bkcolor;
for i:=9 to 14 do
tshape(smsfrm.FindComponent('shape'+inttostr(i))).Visible :=true;
end;

procedure Tsmsfrm.sgDblClick(Sender: TObject);
begin
if r>1 then
memomsg.Text :=sg.Cells[1,r];
end;

procedure Tsmsfrm.SpeedButton2Click(Sender: TObject);
var
b:boolean;
begin
if trim(edtname.Text)='' then
begin
messagebox(handle,'请输入姓名。','警告',mb_ok or mb_iconwarning);
edtname.SetFocus;
exit;
end;
if (trim(edtphone.Text)='')or(length(trim(edtphone.Text))<>11) then
begin
messagebox(handle,'请输入朋友的手机号码(11位)。','警告',mb_ok or mb_iconwarning);
edtphone.SetFocus;
exit;
end;
b:=rb1.Checked;
writeini(trim(edtname.Text),b,trim(edtphone.text),trim(memo1.Text));
readini;
updatephone;
edtname.Clear;
edtphone.Clear;
memo1.Clear;
edtname.SetFocus;
end;

procedure Tsmsfrm.sg2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
sg2.MouseToCell(x,y,c,cr);
end;

procedure Tsmsfrm.SpeedButton4Click(Sender: TObject);
begin
if cr1<1 then exit;
if messagebox(handle,pchar('您真的要删除"'+trim(sg2.Cells[1,cr1])+'"的联系信息吗?'),'警告',mb_yesno or mb_iconwarning)=id_yes then
begin
deleteini(trim(sg2.Cells[1,cr1]),trim(sg2.Cells[3,cr1]));
readini;
updatephone;
cr1:=0;
end;
end;

procedure Tsmsfrm.sg2Click(Sender: TObject);
begin
cr1:=cr;
end;

procedure Tsmsfrm.myphonebookChange(Sender: TObject);
var
i:integer;
begin
if myphonebook.ItemIndex >-1 then
begin
frendcode.Items.Clear;
for i:=1 to myphonebook.Items.Count do
if trim(myphonebook.Text)=userlist[i-1].name then
begin
frendcode.Items.Add(userlist[i-1].phone);
end;
if frendcode.Items.Count >0 then
frendcode.ItemIndex :=0;
end;
end;

procedure Tsmsfrm.edtnameKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
edtphone.SetFocus;
edtphone.SelectAll;
exit;
end;
end;

procedure Tsmsfrm.edtphoneKeyPress(Sender: TObject; var Key: Char);
begin
if (key<'0')or(key>'9') then
if key<>#8 then key:=#0;

end;

procedure Tsmsfrm.SpeedButton3Click(Sender: TObject);
begin
if cr1<1 then exit;
modifrm.showmodal;
end;

procedure Tsmsfrm.sg2DblClick(Sender: TObject);
begin
cr1:=cr;
if cr1>0 then
modifrm.ShowModal;
end;

procedure Tsmsfrm.Shape10MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
sp:tshape;
k:string;
begin
sp:=(sender as tshape);
sp.Visible :=false;
k:=sp.Name;
k:=copy(k,6,length(k)-5);
tshape(smsfrm.FindComponent('shape'+inttostr(strtoint(k)-6))).pen.color:=clblue;
end;

procedure Tsmsfrm.btntimesendClick(Sender: TObject);
begin
ismodi:=true;
regfrm.showmodal;
end;

procedure Tsmsfrm.Label13Click(Sender: TObject);
begin
shellexecute(0,nil,'http://www.smschina.com',nil,nil,9);
end;

procedure Tsmsfrm.memomsgKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then key:=#0;
end;

end.
 
這麼長,看的頭都暈了.
有沒有完整的例子,發到我的郵箱好嗎:
billfox@yeah.net
 
麻烦大哥发我一个
谢谢。
Dreamer_afei@163.com
 
谢谢,不过我想用网关发短信
 
能不能给我也发一个完整的。不胜感激!
rokoon@963.net
 
后退
顶部