⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 怎样做一个给手机发送短信的程序?.htm

📁 大家可以看看
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0044)http://book.hackbase.com/ask24/how165085.htm -->
<HTML><HEAD><TITLE>怎样做一个给手机发送短信的程序?</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT type=text/javascript><!--google_ad_client = "pub-7325395580237867";google_ad_width = 728;google_ad_height = 90;google_ad_format = "728x90_as";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_url = "FFFFFF";google_color_text = "000000";//--></SCRIPT>

<SCRIPT src="怎样做一个给手机发送短信的程序?.files/ad.htm" type=text/javascript></SCRIPT>

<META content="MSHTML 6.00.2900.3059" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<CENTER>
<SCRIPT src="怎样做一个给手机发送短信的程序?.files/163new.htm" type=text/javascript></SCRIPT>

<TABLE width="100%">
  <TBODY>
  <TR>
    <TD align=right>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" align=right border=0>
        <TBODY>
        <TR>
          <TD colSpan=2><A></A><!--#include file="/header.htm"--><A 
            href="http://book.hackbase.com/index.html">返回首页</A> - <A 
            href="http://book.hackbase.com/index.htm">当前索引</A> - </TD></TR>
        <TR>
          <TD colSpan=2 height=15></TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD align=left>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD vAlign=top align=right width=100>主  题:</TD>
          <TD align=right width=5></TD>
          <TD><PRE>怎样做一个给手机发送短信的程序?</PRE></TD></TR>
        <TR bgColor=#666666>
          <TD colSpan=3 height=1></TD></TR>
        <TR height=10>
          <TD align=right></TD>
          <TD align=right></TD>
          <TD></TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD><PRE>
我想用这个程序给有手机的朋友发短信。工具只有一台能通过局域网上internet的计算机,能做么?好做么?怎么个思路?
</PRE></TD></TR>
  <TR>
    <TD>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD width=10 bgColor=#f1f5fa></TD>
          <TD bgColor=#f1f5fa height=25><FONT color=#3366cc>回复人:<B> 
            Storm2008($$天冰$$) </B></FONT><FONT color=#000000>( ) 信誉:103 
          </FONT></TD>
          <TD bgColor=#f1f5fa height=25><FONT color=#000000>2003-02-13 
            15:15:55Z </FONT></TD>
          <TD bgColor=#f1f5fa height=25><FONT color=#000000>得分:</FONT><FONT 
            color=#000000>0</FONT> </TD></TR>
        <TR>
          <TD bgColor=#0066cc colSpan=4 height=1></TD></TR>
        <TR>
          <TD colSpan=4 height=5></TD></TR>
        <TR>
          <TD><FONT color=#ffffff>?</FONT></TD>
          <TD colSpan=3><PRE>
www.playicq.com有原程序下载
</PRE></TD></TR>
        <TR>
          <TD align=right colSpan=4 height=10><FONT color=#ff6633><B><A 
            href="http://book.hackbase.com/ask24/how165085.htm#top"><FONT 
            color=#3366cc>Top</FONT></A></B></FONT></TD></TR>
        <TR>
          <TD colSpan=4 height=5></TD></TR></TBODY></TABLE>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD width=10 bgColor=#f1f5fa></TD>
          <TD bgColor=#f1f5fa height=25><FONT color=#3366cc>回复人:<B> 
            cg1120(代码最优化-§惟坚韧者始能遂其志§) </B></FONT><FONT color=#000000>( ) 信誉:252 
            </FONT></TD>
          <TD bgColor=#f1f5fa height=25><FONT color=#000000>2003-02-13 
            15:16:21Z </FONT></TD>
          <TD bgColor=#f1f5fa height=25><FONT color=#000000>得分:</FONT><FONT 
            color=#000000>70</FONT> </TD></TR>
        <TR>
          <TD bgColor=#0066cc colSpan=4 height=1></TD></TR>
        <TR>
          <TD colSpan=4 height=5></TD></TR>
        <TR>
          <TD><FONT color=#ffffff>?</FONT></TD>
          <TD colSpan=3><PRE>
转贴:
gordon9673 :用PC通过手机发送短信?我是用手机数据线来发送的,例如用我的PC连好了NOKIA6110的数据线,通过COM1来连接,我察过资料,我的想法是,先用CREATEFILE创建连接,然后用WRITEFILE来传送我的消息,nokia的手机大部分都支持TEXT的格式,是吧,例如,我在EDIT中输入:‘AT ?’,然后用WRITEFILE向COM1发送数据,这样可以吗?如果可以,拿我怎么接收它的返回信息呢?(显示在MEON1)上。

deathcat:发送短消息有很多种方法.第一:控制手机,第二:控制GSM模块,第三:通过短消息网关。在GSM协议中.有MT,ME,不知道你说的究竟是什么,说清楚点。
1.去查阅AT命令集+GSM0707协议+GSM0705协议.
2.从手机制造商哪里下载软件.
根据AT命令集.没有"AT?"这个命令.(但是不知道NOKIA有没有).标准的text文本发送模式:
发送:
at+cmgs="+86(手机号码)"+#13+#10
返回:
&gt;

发送:
消息内容

返回:
+CMGS [发送标号]
OK

至于接收.你用的应该是Comm控件吧,当ReceiveCount&gt;0的时候,缓冲区有数据,用Input的方法就可以读出来了. 

gordon9673 :谢谢。我还想知道用PDU格式发送时,必须把AT命令转化成16进制的数吗?该怎么转换?

gordon9673 (gody) :
这个好象可以啊
http://www.yiwant.com/download1.htm
电脑连接手机收发短消息的二次开发工具,包括一个实现短消息收发功能的DLL、函数说明和一个DELPH程序源代码。
www.yiwant.com/cgi-bin/click.cgi?job=down&amp;filename=sms-delphi


部分程序:
mplementation

{$R *.DFM}
//=============DLL 函数调用声明 开始 =========
    procedure ConnectToMobile;stdcall; external 'SMSLIB.DLL';
    procedure DisconnectToMobile;stdcall; external 'SMSLIB.DLL';
    Function  IsConnected:boolean;stdcall; external 'SMSLIB.DLL';
    Function  IsBusy:boolean;stdcall; external 'SMSLIB.DLL';
    procedure InitMobile;stdcall; external 'SMSLIB.DLL';
    procedure SetSMC(SMC:PChar);stdcall; external 'SMSLIB.DLL';
    Function SendSMS(phone,text:PChar):boolean;stdcall; external 'SMSLIB.DLL';
    Function ReadSMS(Text,sendnum,smc,time:PChar):boolean;stdcall; external 'SMSLIB.DLL';
//=============DLL 函数调用声明 结束 =========

procedure TForm1.Button1Click(Sender: TObject);
begin
    ConnectToMobile;
    memo2.Lines.Add ('已经发出连接命令。');
    sleep(4000);     //等待4秒,等待手机准备好
    while not IsConnected do ;  //直到连接成功

    memo2.Lines.Add ('已经连接到手机。');
    InitMobile;
    memo2.Lines.Add ('已经初始化。');
    SetSMC(PChar(SMC.Text ));
    memo2.Lines.Add ('短信中心设置成功。');

end; 

deathcat:
使用pdu格式可以啊。
at+cmgf=0  ----使用pdu模式
at+cmgf=1  ----使用text模式
但是,你首先要看nokia的手机是否支持pdu格式。
不过,我想应该是支持的。
因为text模式不支持中文短消息。

你要先查查pdu格式手册,每一个短信中心的pdu格式不是很一致的。
没有必要做什么16进制的转换啊。如果发送中文,那么用的是uc2码。

比如说发送给手机号码为123456789ab的手机发送1234。那么pdu格式应该是
0891683108200905f011000b816821436587a9fb0004+短信息内容长度(16进制)+短信息内容
</PRE></TD></TR>
        <TR>
          <TD align=right colSpan=4 height=10><FONT color=#ff6633><B><A 
            href="http://book.hackbase.com/ask24/how165085.htm#top"><FONT 
            color=#3366cc>Top</FONT></A></B></FONT></TD></TR>
        <TR>
          <TD colSpan=4 height=5></TD></TR></TBODY></TABLE>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD width=10 bgColor=#f1f5fa></TD>
          <TD bgColor=#f1f5fa height=25><FONT color=#3366cc>回复人:<B> 
            wjlsmail(计算机质子) </B></FONT><FONT color=#000000>( ) 信誉:105 </FONT></TD>
          <TD bgColor=#f1f5fa height=25><FONT color=#000000>2003-02-13 
            15:17:19Z </FONT></TD>
          <TD bgColor=#f1f5fa height=25><FONT color=#000000>得分:</FONT><FONT 
            color=#000000>0</FONT> </TD></TR>
        <TR>
          <TD bgColor=#0066cc colSpan=4 height=1></TD></TR>
        <TR>
          <TD colSpan=4 height=5></TD></TR>
        <TR>
          <TD><FONT color=#ffffff>?</FONT></TD>
          <TD colSpan=3><PRE>
supermsg.exe 可以 ; 不过有的手机可以接收到而有的不能,如需要可 Email 你
</PRE></TD></TR>
        <TR>
          <TD align=right colSpan=4 height=10><FONT color=#ff6633><B><A 
            href="http://book.hackbase.com/ask24/how165085.htm#top"><FONT 
            color=#3366cc>Top</FONT></A></B></FONT></TD></TR>
        <TR>
          <TD colSpan=4 height=5></TD></TR></TBODY></TABLE>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD width=10 bgColor=#f1f5fa></TD>
          <TD bgColor=#f1f5fa height=25><FONT color=#3366cc>回复人:<B> 
            cg1120(代码最优化-§惟坚韧者始能遂其志§) </B></FONT><FONT color=#000000>( ) 信誉:252 
            </FONT></TD>
          <TD bgColor=#f1f5fa height=25><FONT color=#000000>2003-02-13 
            15:17:43Z </FONT></TD>
          <TD bgColor=#f1f5fa height=25><FONT color=#000000>得分:</FONT><FONT 
            color=#000000>0</FONT> </TD></TR>
        <TR>
          <TD bgColor=#0066cc colSpan=4 height=1></TD></TR>
        <TR>
          <TD colSpan=4 height=5></TD></TR>
        <TR>
          <TD><FONT color=#ffffff>?</FONT></TD>
          <TD colSpan=3><PRE>
用GSM模块发中文短讯,必须以PDU包的形式发送。我将它写成了Dll,直接调用SMSEncode函数即可得到追后的编码。现将原码公开:
unit EnCodeCompnent;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

    function SMSEncode(s:WideString;Result_Code:pchar):Bool;Stdcall;export;
    function SMSDecode(Input_Code:pchar;Result_Str:pchar):Bool;Stdcall;export;
    function MakePDU(DestNumber:pchar;Content:pchar;Result_String:pchar):Bool;stdcall;export;
    function ConvertPhoneNum(strNum:string):string;
    function Transposition(instr:pchar;Result_str:pchar):Bool;stdcall;export;//将一个字符串两两交换位置
    { Public declarations }

implementation


function SMSEncode(s:WideString;Result_Code:pchar):Bool;
var
  i,len:Integer;
  cur:Integer;
  t,temp:String;
begin
if length(s)&gt;0 then
  begin
    len:=Length(s);
    i:=1;
    while i&lt;=len do
      begin
        cur:=ord(s[i]);
        //BCD convert
        FmtStr(t,'%4.4X',[cur]);
        temp:=temp+t;
        inc(i);
      end;
    StrCopy(Result_Code,pchar(temp));
    Result:=true;
  end
else
  Result:=false;
end;

function SMSDecode(Input_Code:pchar;Result_Str:pchar):Bool;
var
  str:string;
  i:integer;
  temp:string;
  A_PWideChar:array[0..300] of widechar;
  R_String:string;
  A_integer:integer;
begin
  str:=string(Input_Code);
  R_String:='';
  if length(str)&lt;=0 then
    begin
      Result:=false;
      exit;
    end;
  i:=0;
  while i&lt;length(str) do
    begin
      temp:=copy(str,i+1,4);
      A_integer:=strtoint('$'+temp);
      move(A_integer,A_PWideChar[i div 4],sizeof(A_PWideChar[i div 4]));
      inc(i,4);
    end;
  A_PWideChar[length(str) div 4]:=#0;
  R_String:=WideCharToString(@A_PWideChar);
  StrCopy(Result_Str,pchar(R_String));
  Result:=true;
end;


function MakePDU(DestNumber:pchar;Content:pchar;Result_String:pchar):Bool;
const
  lenSmsInfo='00';
  firstOctet='11';
  TPMessageReference='00';
  TypeOfAddress='91';
  TpId='00';
  TpDcs='08';//"00" is 7 bit encode "08" is 8 bit encode;
  TPValidityPeriod='AA';//aa is 4 day
var
  DestPhoneNum:string;
  AddressLength:string;
  TpUserData:string;
  TPUserDataLength:string;
  temp:WideString;
  Tmp_Pchar:pchar;
  Rlt_str:string;
begin
  if (DestNumber='') or (Content='') then
    begin
      Result:=false;
      exit;
    end
  else
    begin
      DestPhoneNum:=ConvertPhoneNum(DestNumber);
      AddressLength:=format('%2.2X',[length(DestNumber)]);
      temp:=Content;
      Tmp_Pchar:=StrAlloc(1000);
      if SMSEncode(temp,Tmp_Pchar) then
        TpUserData:=string(Tmp_Pchar);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -