這是一個關於簡訊的程式
該如何把它 只寫成一個procedure呢?....讓其他人若想要使用這支程式 只要下面加參數去呼叫他就可以了
希望各位大大可以幫忙,指點!!謝謝
procedure TForm1.Label2Click(Sender: TObject);
begin
ShellExecute(Handle,'open','http://www.twsms.com',nil,nil,SW_SHOWNORMAL); //(連結)
end;
procedure TForm1.IdLogEvent1Received(ASender: TComponent; const AText,//(StdCtrls)
AData: String);
begin
LogList.Items.Add('Received :' AText ';' AData);
LogList.ItemIndex := LogList.Count-1;
end;
procedure TForm1.IdLogEvent1Sent(ASender: TComponent; const AText, //( ComCtrls)
AData: String);
begin
LogList.Items.Add('Sent :' AText ';' AData);
LogList.ItemIndex := LogList.Count-1;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var Content : Tstrings;
Response,ResDesc : string; //(主動式回傳簡訊接收狀態)
i : integer;
begin
if Length(SMSUser.Text)* Length(SMSPwd.Text)*
Length(SendToNo.Text)* Length(SendMsg.Text) = 0 then //(HTTP來檢查簡訊發送狀況)
raise Exception.Create('資料輸入不完整 !');
if ProxyHost.Text <> '' then begin
IdHTTP1.ProxyParams.ProxyServer := ProxyHost.Text;
IdHTTP1.ProxyParams.ProxyPort := ProxyPort.Value;
IdHTTP1.ProxyParams.ProxyUsername := ProxyUser.Text;//(帳號)
IdHTTP1.ProxyParams.ProxyPassword := ProxyPwd.Text; //(密碼)
end;
Content := TStringList.Create;
try
for i := 0 to SendToNo.Lines.Count - 1 do
if Trim(SendToNo.Lines[i])<>'' then begin
StatusBar1.SimpleText := '傳送給 : ' SendToNo.Lines[i] ' 中...';
Content.Text := 'CID=' SMSUser.Text '&CPW=' SMSPwd.Text '&N=' SendToNo.Lines[i]
'&M=' IdHTTP1.URL.ParamsEncode(SendMsg.Text);
try
Response := IdHTTP1.Post(web,Content);
except
on E: Exception do begin
LogList.Items.Add(DateTimeToStr(now) '; 錯誤發生 : ' E.Message);
if IdHTTP1.Connected then IdHTTP1.Disconnect;
end;
end;
if pos(':',Response)>0 then
Response := Trim(Copy(Response,1,pos(':',Response)-1));
ResDesc := Memo1.Lines.Values[Response];
StatusBar1.SimpleText := ResDesc;
LogList.Items.Add(DateTimeToStr(now) '; 傳送給 : ' SendToNo.Lines[i] ' ; 結果 : ' ResDesc);
Sleep(3000);
end;
finally
if IdHTTP1.Connected then IdHTTP1.Disconnect;
LogList.Items.SaveToFile('SMSLog.txt'); //(有無連結 存檔)
if Content<>nil then Content.Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
if FileExists('ErrCode.txt') then Memo1.Lines.LoadFromFile('ErrCode.txt');//(讀檔)
end;
procedure TForm1.IdLogEvent1Status(ASender: TComponent; //(ExtCtrls)
const AText: String);
begin
LogList.Items.Add('Status :' AText);
LogList.ItemIndex := LogList.Count-1;
end;
end.