我做的是电脑通过gsm给手机发送短信,我用delphi编的用的mscomm控件
程序编译能够通过但是就是手机收不到信息
下面是我的应用程序我先想试试TExt格式的发送:
unit sms;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleCtrls, MSCommLib_TLB;type
  TForm1 = class(TForm)
    MSComm1: TMSComm;
    Label1: TLabel;
    Label2: TLabel;
    Memo1: TMemo;
    Edit2: TEdit;
    Button1: TButton;
    function OpenPort():Boolean;
    procedure inisms();
    procedure sendinencodetext(sms:string;mobile:string);
    procedure sendsms(mobile:string);
    procedure Button1Click(Sender: TObject);
    //procedure Button2Click(Sender: TObject);  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}
function TForm1.OpenPort:Boolean;
begin
//更新mscomm的设置
 try
   mscomm1.CommPort:=2;
   mscomm1.Settings:='9600,n,8,1';
   mscomm1.InBufferSize:=1024;
   mscomm1.InBufferCount:=0;
   mscomm1.InputMode:=1;
   mscomm1.InputLen:=0;
   mscomm1.PortOpen:=true;
   OpenPort:=mscomm1.PortOpen;
 except
   OpenPort:=false;
   //messagebox(self.Handle,pchar('串口‘+pchar(intToStr(mscomm1.commport))+'打开失败!,请更换其他串口'),'串口打开失败',MB_OK);
   end;
   end;
procedure TForm1.inisms;
var
 senddata:string;
 begin
 //先判断串口是否打开
 if not mscomm1.portopen then
 exit;
 senddata:='AT+CMGF=1'+chr(13);
 mscomm1.Output:=senddata;
 //设置短信中心号码
 senddata:='AT+CSCA=8613010370500'+chr(13);
 mscomm1.Output:=senddata;
 end;
 procedure TForm1.sendinencodetext(sms:string;mobile:string);
 var
 strout:string;
 //mobile:string;
 //sms:string;
 begin
 mobile:=Edit2.Text;
 //sms:=Memo1.Text;
 strout:='AT+CMGS="'+mobile+'"'+chr(13);
 mscomm1.Output:=strout;
 strout:=sms+chr(26);
 mscomm1.Output:=strout;
 end;
 procedure TForm1.sendsms(mobile:string);
 var
 //i:integer;
 strsms:string;
 begin
 if length(mobile)<>11 then
 begin
 showmessage('目标手机号不正确,发送短信失败!');
 end;
 //打开串口
 if not OpenPort() then
 exit;
 //初始化短消息,制定短消息编码模式和短消息中心地址
 inisms();
 //发送短消息
 strsms:=Memo1.Text;
 sendinencodetext(strsms,mobile);
 //关闭串口
 mscomm1.PortOpen:=false;
 end;
procedure TForm1.Button1Click(Sender: TObject);
begin
sendsms(Edit2.Text);
 end;
//procedure TForm1.Button2Click(Sender: TObject);
//begin//end;end.