国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 網(wǎng)絡(luò)通信 > 正文

編寫(xiě)SMS程序入門

2019-11-04 22:08:56
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

IntrodUCtion To application PRogramming With SMS
編寫(xiě)SMS程序入門

Microsoft Corporation
October 2002
Applies to:
    Pocket PC 2002 Phone Edition
    Microsoft® eMbedded Visual Tools
版權(quán)聲明:本文的著作權(quán)屬英文原文作者,答應(yīng)非商業(yè)性轉(zhuǎn)載請(qǐng)注明原文出處、翻譯者并保持該文的完整性。謝絕商業(yè)性轉(zhuǎn)載,如有需要請(qǐng)自行和原文作者及翻譯者聯(lián)系。
Summary: Learn how to Send SMS messages from your eMbedded Visual Basic applications. Take advantage of Pocket PC 2002 Phone Edition's robust support for SMS (Short Message Service) when you build your applications.
概要:學(xué)習(xí)如何使用你的eMbedded Visual Basic應(yīng)用程序發(fā)送SMS消息。當(dāng)你創(chuàng)建程序時(shí),需要得到Pocket PC 2002 Phone Edition 對(duì)SMS(短消息服務(wù))的充分支持。
Download the introapp.exe from the MSDN Code Center.
Contents

SMS and Pocket PC Phone Edition
SMS-Enabled Applications
Sending SMS Sample
Code Walkthrough
Conclusion
SMS and Pocket PC Phone Edition
SMS和Pocket PC Phone版本

Short Message Service is a standard for sending short alpha-numeric messages (max 160 characters) between mobile phones in Global System for Mobile Communications networks (GSM). It works much like paging, but with text, and most phones today have support for SMS.
Short Message Service是通過(guò)Mobile Communications networks (GSM)的全球系統(tǒng)在移動(dòng)電話間發(fā)送short alpha-numeric messages(最多160字符)的標(biāo)準(zhǔn)。它像尋呼機(jī)一樣工作,只是用于文本格式,現(xiàn)在的大多數(shù)電話都支持SMS。
A key aspect of SMS is that messages are sent through the mobile network Operator's network instantly, without the need to manually connect to an Internet Service Provider—SMS messages are instantly delivered while e-mails need to be retrieved from a mail server by the receiver. Also, if the receiver is not online—if the phone is turned off—the SMS message is stored at the operator and forwarded when the phone is turned back on.
SMS的一個(gè)要害特點(diǎn)是,通過(guò)無(wú)線網(wǎng)絡(luò)服務(wù)器的網(wǎng)絡(luò)立即發(fā)送,不需要手動(dòng)連接到Internet Service Provider—SMS消息是立即發(fā)送,而e-mails需要通過(guò)接收器從郵件服務(wù)器上接收。同樣,假如接收器沒(méi)有在線—假如電話關(guān)閉—SMS消息被儲(chǔ)存在服務(wù)器中,當(dāng)電話打開(kāi)時(shí)再轉(zhuǎn)發(fā)。
On Pocket PC 2002 Phone Edition devices, you can manage SMS messages much in the same way that you manage e-mail messages. The SMS Messaging component is integrated with the standard Inbox application, allowing you to send and receive messages in the same way you send and receive e-mails. You can even forward and reply to e-mails as SMS messages, and vice versa.
在Pocket PC 2002 的電話版設(shè)備上,你可以和治理e-mail消息一樣來(lái)治理SMS消息。SMS消息組件是一個(gè)完整的標(biāo)準(zhǔn)收件箱應(yīng)用程序,答應(yīng)你像收發(fā)電子郵件一樣,收發(fā)SMS消息。你也可以轉(zhuǎn)發(fā)和回復(fù)SMS消息,像電子郵件一樣。
SMS-Enabled Applications
SMS-Enabled 應(yīng)用程序


Many business scenarios involve notifications of some sort, and SMS is a great way to implement notifications for a variety of business events. It could be a salesman that notifies a service engineer of a customer in need of service, a service engineer notifying an executive of an important business event at the customer, or an executive informing all staff related to the customer about new customer handling routines.
許多商業(yè)機(jī)構(gòu)忙碌于對(duì)一些通知的選擇,SMS是一條極好的實(shí)現(xiàn)適應(yīng)變化多樣的商業(yè)事件消息通知的途徑。它可以讓一個(gè)銷售人員向售后服務(wù)工程師轉(zhuǎn)達(dá)消費(fèi)者的需求,一個(gè)服務(wù)工程師向經(jīng)理發(fā)送一個(gè)重要的商務(wù)事件,或者一個(gè)經(jīng)理向全體員工發(fā)送新的消費(fèi)者操作辦法。
Another interesting use of SMS is to enable mobile commerce (m-commerce), as SMS is often used for handling payment transactions. To get you started, we will show you how to send SMS messages from your Pocket PC 2002 Phone Edition device in the following example.
SMS另一個(gè)有趣的應(yīng)用是能夠進(jìn)行移動(dòng)商務(wù)(m-commerce),SMS經(jīng)常被用來(lái)辦理付款事物。我們將通過(guò)下面的例子,演示如何從你的Pocket PC 2002 Phone Edition設(shè)備中發(fā)送SMS消息。
Sending SMS Sample
發(fā)送SMS示例

A simple form using Microsoft® eMbedded Visual Basic®:
這個(gè)例子使用Microsoft® eMbedded Visual Basic® 編寫(xiě):

Figure 1. SMS Sample application
In this form, you can enter an international mobile phone number and a text message. When you hit the Send button, the message is sent—as simple as that!
在這個(gè)窗體中,你可以輸入一個(gè)世界范圍內(nèi)的移動(dòng)電話號(hào)碼和一條文本消息。當(dāng)你點(diǎn)擊發(fā)送按忸,這條消息就被發(fā)送出去了—就這么簡(jiǎn)單。
Code Walkthrough
代碼示例

Let's look at the core of the code for sending SMS messages. First of all, you need to declare a number of Microsoft Windows® APIs:
讓我們來(lái)看發(fā)送SMS消息代碼的核心部分。首先,你需要聲明一系列的Microsoft Windows® APIs:
·                     One for opening the SMS Messaging component
·                     One for sending SMS messages
·                     And one for closing the SMS Messaging component:
·                     一個(gè)函數(shù)是打開(kāi)SMS消息組件
·                     一個(gè)函數(shù)是發(fā)送SMS消息
·                     另一個(gè)函數(shù)是關(guān)閉SMS消息組件
·                           Public Declare Function SmsOpen Lib "SMS" (ByVal ptsMessageProtocol
·                             As String, ByVal dwMessageModes As Long, ByRef psmshHandle As
·                             Long, ByRef phMessageAvailableEvent As Long) As Long
·                           
·                           Public Declare Function SmsSendMessage Lib "SMS" (ByVal smshHandle
·                             As Long, ByVal psmsaSMSCAddress As Long, ByVal
·                             psmsaDestinationAddress As String, ByVal pstValidityPeriod As
·                             Long, ByVal pbData As String, ByVal dwDataSize As Long, ByVal
·                             pbProviderSpecificData As String, ByVal dwProviderSpecificDataSize
·                             As Long, ByVal smsdeDataEncoding As Long, ByVal dwOptions As Long,
·                             ByRef psmsmidMessageID As Long) As Long
·                           
·                           Public Declare Function SmsClose Lib "SMS" (ByVal smshHandle As
·                             Long) As Long


You also need some API constants declared for the different APIs:
你也需要為這些API聲明一些API常量:
Public Const SMS_MSGTYPE_TEXT = "Microsoft Text SMS Protocol"
Public Const SMS_MODE_SEND = 2            ' Open in send mode
Public Const SMSDE_GSM = 1                ' Use standard GSM
  encoding
Public Const SMSAT_INTERNATIONAL = 1      ' International number
  format
Public Const PS_MESSAGE_OPTION_NONE = 0   ' No message options
Public Const PS_MESSAGE_CLASS0 = 0        ' Send immediately
Public Const PSRO_NONE = 0                ' No replacements
Public Const SMS_OPTION_DELIVERY_NONE = 0 ' No delivery options

The following is the complete code to send an SMS message:
下面是發(fā)送一條SMS消息的完整代碼:
Public Sub SendSMS(ByVal Number As String, ByVal Message As String)
 
  Dim SMSHandle As Long
  Dim SMSEvent As Long
  Dim SMSAddress As String
  Dim SMSProvider As String
 
  ' Open SMS Messaging Component
  Call SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, SMSHandle, SMSEvent)
 
  ' Set Address structure (UDT as string)
  SMSAddress = LongToBytes(SMSAT_INTERNATIONAL) & Number
 
  ' Set Provider structure (UDT as string)
  SMSProvider = LongToBytes(PS_MESSAGE_OPTION_NONE) & _
                LongToBytes(PS_MESSAGE_CLASS0) & _
                LongToBytes(PSRO_NONE)
 
  ' Send message
  If 0 = SmsSendMessage(SMSHandle, 0, SMSAddress, 0, Message, _
         LenB(Message), SMSProvider, 12, SMSDE_GSM, _
         SMS_OPTION_DELIVERY_NONE, 0) Then
    MsgBox "Message sent!", vbInformation, App.Title
  Else
    MsgBox "Could not send message!", vbCritical, App.Title
  End If
 
  ' Close SMS Messaging Component
  Call SmsClose(SMSHandle)
 
End Sub

First, the SMS Messaging component is opened (SmsOpen) and its handle is stored (SMSHandle). This handle is needed to call other SMS APIs.
首先,SMS消息組件要被打開(kāi)(SmsOpen),并且它的句柄被儲(chǔ)存(SMSHandle)。調(diào)用其他的SMS API需要使用這個(gè)句柄。
A number of structures or UDTs (User Defined Types) need to be prepared for thecall to SmsSendMessage. Since eMbedded Visual Basic lacks support for UDTs, simple strings are used to emulate a structure.
SmsSendMessage調(diào)用的結(jié)構(gòu)的成員和UDTs(用戶定義類型)需要被初始化,因?yàn)閑Mbedded Visual Basic不支持UDTs,簡(jiǎn)單的字符串被用來(lái)模擬一個(gè)結(jié)構(gòu)。
The first is a structure containing the address of the SMS message. The address structure contains an indicator of what kind of number is supplied (in this case an international number) and the number itself.
The next structure contains various options regarding the service provider. The first part of the structure indicates that no special options are selected, and the second part indicates that the message should be sent immediately.
結(jié)構(gòu)中包含的第一個(gè)是SMS消息的地址。結(jié)構(gòu)的第一部分指出沒(méi)有特定的選項(xiàng)被選擇,第二部分指出消息將被馬上發(fā)送。
The last part states that no replacement should be made.
最后一部分指出沒(méi)有復(fù)位(replacement)存在。
In the call to send the message (SmsSendMessage), the prepared structures are supplied, the message text and a number of options. Finally, the handle is closed (SmsClose).
在發(fā)送消息的調(diào)用中(SmsSendMessage),預(yù)備好的結(jié)構(gòu),消息文本和號(hào)碼的選項(xiàng)將被提供。最后,這個(gè)句柄被關(guān)閉(SmsClose)。
For a complete example, see this article's sample code. Also, you can read more about this technique in Antonio Paneiro's article, UDTs (User Defined Types) with VBCE.
完整的示例請(qǐng)看文章的示例代碼。同樣,你可以在Antonio Paneiro的文章中得到更多關(guān)于這項(xiàng)技術(shù)的知識(shí),UDTs (User Defined Types) with VBCE.
Conclusion
結(jié)論


SMS is great for small and instant text notifications. And with the support in Pocket PC 2002 Phone Edition, you will be able to make your applications "SMS aware." With the sample code from this example, you have most of what you need to get going. If you accept that the mobile world, in terms of communication mechanisms and protocols, is more about "both/and" rather than "or/else," you pragmatically can use each option when suitable.SMS對(duì)于短小的直接的文本通知來(lái)說(shuō)是非常好的。在Pocket PC 2002 Phone Edition的支持下,你可以創(chuàng)建你的應(yīng)用程序"SMS aware"。通過(guò)和示例相同的代碼,你可以得到更多你需要的。假如你接受移動(dòng)世界,根據(jù)通訊機(jī)制和協(xié)議,"both/and"優(yōu)于"or/else",你可以根據(jù)情況使用合適的選項(xiàng)。



發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 嵊泗县| 峡江县| 常德市| 秦皇岛市| 甘洛县| 山阳县| 乐业县| 天门市| 绥宁县| 涡阳县| 镇赉县| 永德县| 泸溪县| 忻州市| 青铜峡市| 永顺县| 余庆县| 贺兰县| 新闻| 柳河县| 嘉祥县| 石门县| 湖州市| 闸北区| 社会| 株洲市| 呼玛县| 泰顺县| 门源| 宜城市| 营口市| 武穴市| 麟游县| 肇庆市| 南木林县| 杭锦后旗| 醴陵市| 开原市| 班戈县| 丽水市| 长武县|