中華電信簡訊發送程式 |
|
mine
中階會員 發表:28 回覆:129 積分:56 註冊:2004-03-31 發送簡訊給我 |
該死的中華電信提供了一堆程式就缺delphi的 這樣算創作嗎
小的環境 class="code">
unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient; type
Send_Msg=Record
interface_type:Byte;
msg_type:Byte;
msg_content_len:Byte;
msg_content:array[0..255] of Char;
end;
//Send_Type 'd' (send right now), 'e' (Send when appointment time)
//if SendType equal e Msg_Content must contain Send Time.
//Style ex: 經測試如果不送截送時間HINET 就會當成送到成功為止
//Send record{
// GSMNO:pchar;
// SendMessage:pchar;
// Send_type:pchar;
//(appointmenttime)Send_Time:DataTime(Format(YYMMDDhhmmss))ps:ss equal:=0;
//(Repeat Halt Time)Stop_Time:DataTime(Format(YYMMDDhhmmss))ps:ss equal:=0;} type
Ret_Msg=Record
ret_code:Byte;
ret_description:array[0..255] of Char;
end; Const
INTERFACE_TYPE=0; type
TForm1 = class(TForm)
IdTCPClient1: TIdTCPClient;
Button1: TButton;
Button2: TButton;
Button4: TButton;
Button5: TButton;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Label4: TLabel;
Edit4: TEdit;
Label5: TLabel;
Edit5: TEdit;
Memo1: TMemo;
Edit6: TEdit;
Label6: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure IdTCPClient1Status(ASender: TObject;
const AStatus: TIdStatus; const AStatusText: String);
procedure Button4Click(Sender: TObject);
procedure Memo1Change(Sender: TObject);
private
RetMsg:Ret_Msg;
SendMsg:Send_Msg;
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);
begin
Try
IdTCPClient1.Host:=Trim(Edit1.Text);
IdTCPClient1.Port:=StrToInt(Edit2.Text);
if IdTCPClient1.Connected=False then
IdTCPClient1.Connect(900);
except
ShowMessage('無法連線,請檢查設定是否正確');
end
end; procedure TForm1.Button2Click(Sender: TObject);
begin
IdTCPClient1.Disconnect;
end; procedure TForm1.Button3Click(Sender: TObject);
var
UserId:Pchar;
pass:Pchar;
conmsg:array[0..255] of Char;
begin
ShowMessage(StrPas(RetMsg.ret_description));
end; procedure TForm1.Button5Click(Sender: TObject);
var
Msgpos:Integer;
begin
Try
if IdTCPClient1.Connected=False then begin
IdTCPClient1.Host:=Trim(Edit1.Text);
IdTCPClient1.Port:=StrToInt(Edit2.Text);
IdTCPClient1.Connect(900);
end;
except
ShowMessage('無法連線,請檢查設定是否正確?');
Exit;
end;
Msgpos:=0;
SendMsg.interface_type:=INTERFACE_TYPE;
SendMsg.msg_type:=0;
Msgpos:=Length(strcopy(@SendMsg.msg_content[Msgpos],Pchar(Trim(Edit3.Text)))) 1;
Msgpos:=MSgpos Length(strcopy(@SendMsg.msg_content[Msgpos],Pchar(Trim(Edit4.Text)))) 1;
IdTCPClient1.Socket.Send(SendMsg,Sizeof(SendMsg));
IdTCPClient1.Socket.Recv(RetMsg,Sizeof(RetMsg));
ShowMessage(StrPas(RetMsg.ret_description));
if RetMsg.ret_code=0 then
Showmessage('已登入')
else
IdTCPClient1.Disconnect;
FillChar(SendMsg.msg_content,Sizeof(SendMsg.msg_content),0);
end; procedure TForm1.IdTCPClient1Status(ASender: TObject;
const AStatus: TIdStatus; const AStatusText: String);
begin
Case AStatus of
hsResolving: ;
hsConnecting:ShowMessage('連線中...');
hsConnected:ShowMessage('連線成功');
hsDisconnecting:ShowMessage('結束連線中...');
hsDisconnected:ShowMessage('結束連線');
hsStatusText:;
ftpTransfer:;
ftpReady:;
ftpAborted:;
else
ShowMessage('不明狀態');
end;
end; procedure TForm1.Button4Click(Sender: TObject);
var
Msgpos:Integer;
begin
if IdTCPClient1.Connected=False then begin
ShowMessage('尚未連線,請先連線');
Exit;
end;
Msgpos:=0;
SendMsg.interface_type:=INTERFACE_TYPE;
SendMsg.msg_type:=1;
Msgpos:=Length(strcopy(@SendMsg.msg_content[MsgPos],Pchar(Trim(Edit5.Text)))) 1;//gsmNo
Msgpos:=MSgpos Length(strcopy(@SendMsg.msg_content[Msgpos],Pchar(Trim(Memo1.Text)))) 1;//sendmsg;
MSgpos:=MSgpos Length(strcopy(@SendMsg.msg_content[Msgpos],Pchar(String('d')))) 1;//Sendtype
Msgpos:=MSgpos Length(strcopy(@SendMsg.msg_content[Msgpos],Pchar(String('')))) 1;//Repeat Stop time
IdTCPClient1.Socket.Send(SendMsg,Sizeof(SendMsg));
IdTCPClient1.Socket.Recv(RetMsg,Sizeof(RetMsg));
if RetMsg.ret_code=0 then
Showmessage('發送完成 ');
ShowMessage(StrPas(RetMsg.ret_description));
FillChar(SendMsg.msg_content,Sizeof(SendMsg.msg_content),0);
end; procedure TForm1.Memo1Change(Sender: TObject);
var
i:Integer;
temp:Widestring;
Cflag:Boolean;
begin
Cflag:=False;
if Length(Memo1.Text)>=0 then
for i:=1 to Length(Memo1.Text) do begin
if CharLength(memo1.text,i)= 2 then
Cflag:=True;
end;
if Cflag=True then
Edit6.Text:=IntToStr(Length(WideString(Memo1.Text))*2)
else
Edit6.Text:=IntToStr(Length(Memo1.Text));
if StrToInt(Edit6.Text)=140 then
ShowMessage('中英文混合字數已到最大數' #13 #10 '超過此字數簡訊無法送達');
if StrToInt(Edit6.Text)=160 then
ShowMessage('英數字元已到最大數' #13 #10 '超過此字數簡訊無法送達');
end; end.
搞不懂!搞不懂!永遠都搞不懂!!
附加檔案:59068_SMS.rar
|
039917
一般會員 發表:9 回覆:16 積分:5 註冊:2003-09-14 發送簡訊給我 |
|
mine
中階會員 發表:28 回覆:129 積分:56 註冊:2004-03-31 發送簡訊給我 |
|
039917
一般會員 發表:9 回覆:16 積分:5 註冊:2003-09-14 發送簡訊給我 |
|
暗黑破壞神
版主 發表:9 回覆:2301 積分:1627 註冊:2004-10-04 發送簡訊給我 |
|
039917
一般會員 發表:9 回覆:16 積分:5 註冊:2003-09-14 發送簡訊給我 |
|
thomas0728
中階會員 發表:112 回覆:260 積分:89 註冊:2002-03-12 發送簡訊給我 |
|
mine
中階會員 發表:28 回覆:129 積分:56 註冊:2004-03-31 發送簡訊給我 |
|
dreameryeh
一般會員 發表:6 回覆:9 積分:3 註冊:2005-08-17 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |