成都创新互联网站制作重庆分公司

vb.net手机短信 c#短信

C#实现发送短信到手机功能

常见两种方式:

10年积累的网站建设、成都做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站策划后付款的网站建设流程,更有垦利免费网站建设让你可以放心的选择与我们合作。

使用短信网关,有第三方的,也有和移动电信等签约的。后者一般是大客户才开放。前者你百度搜“短信通”就可以找到很多家提供这种服务的公司。提供的接口一般是http协议的调用。在C# WINFORM里就可以使用WebClient类来调用了。具体的接口你还是得看不同公司提供的文档。

使用短信猫。是一个硬件设备,可以插SIM卡,然后通过短信猫提供的API去调用…具体还是得看那个API…我用过一个是提供一个dll给你import的。其他应该也一样

Visual C#实现短信息发送的具体实现步骤:

Visual C#发送短信息的关键就是通过Web引用新浪网提供的发送短信息的Web Service,并在引用完成后。调用此Service的sendXml方法即可。以下就是Visual C#引用Web Service发送短信息的具体实现步骤:

1. 启动Visual Studio .Net。

2. 选择菜单【文件】|【新建】|【项目】后,弹出【新建项目】对话框。

3. 将【项目类型】设置为【Visual Basic项目】。

4. 将【模板】设置为【Windows应用程序】。

5. 在【名称】文本框中输入【短信】。

6. 在【位置】的文本框中输入【E:/VS.NET项目】,然后单击【确定】按钮,这样在"E:/VS.NET项目"目录中就产生了名称为"短信"的文件夹,并在里面创建了名称为"短信"的项目文件。

7. 把Visual Studio .Net的当前窗口切换到【Form1.cs(设计)】窗口,并从【工具箱】中的【Windows窗体组件】选项卡中往Form1窗体中拖入下列组件,并执行相应的操作:

四个Label组件。

四个TextBox组件。

一个Button组件,其作用是发送短信息。并在这个Button组件拖入Form1的设计窗体后,双击它,则系统会在Form1.cs文件分别产生这个组件的Click事件对应的处理代码。

8. 把Visual Studio .Net的当前窗口切换到Form1.vb的代码编辑窗口,并用下列代码替换Form1.cs中的InitializeComponent过程对应的代码,下列代码作用是初始化窗体中加入的组件:

private void InitializeComponent ( )

{

this.textBox1 = new System.Windows.Forms.TextBox ( ) ;

this.textBox2 = new System.Windows.Forms.TextBox ( ) ;

this.textBox3 = new System.Windows.Forms.TextBox ( ) ;

this.button1 = new System.Windows.Forms.Button ( ) ;

this.label1 = new System.Windows.Forms.Label ( ) ;

this.label2 = new System.Windows.Forms.Label ( ) ;

this.label3 = new System.Windows.Forms.Label ( ) ;

this.label4 = new System.Windows.Forms.Label ( ) ;

this.textBox4 = new System.Windows.Forms.TextBox ( ) ;

this.SuspendLayout ( ) ;

this.textBox1.Location = new System.Drawing.Point ( 144 , 16 ) ;

this.textBox1.Name = "textBox1" ;

this.textBox1.Size = new System.Drawing.Size ( 184 , 21 ) ;

this.textBox1.TabIndex = 0 ;

this.textBox1.Text = "" ;

this.textBox2.Location = new System.Drawing.Point ( 144 , 69 ) ;

this.textBox2.Name = "textBox2" ;

this.textBox2.PasswordChar = ''''''''*'''''''' ;

this.textBox2.Size = new System.Drawing.Size ( 184 , 21 ) ;

this.textBox2.TabIndex = 1 ;

this.textBox2.Text = "" ;

this.textBox3.Location = new System.Drawing.Point ( 144 , 122 ) ;

this.textBox3.Name = "textBox3" ;

this.textBox3.Size = new System.Drawing.Size ( 184 , 21 ) ;

this.textBox3.TabIndex = 2 ;

this.textBox3.Text = "" ;

this.button1.Location = new System.Drawing.Point ( 152 , 256 ) ;

this.button1.Name = "button1" ;

this.button1.Size = new System.Drawing.Size ( 80 , 32 ) ;

this.button1.TabIndex = 4 ;

this.button1.Text = "发送" ;

this.button1.Click += new System.EventHandler ( this.button1_Click ) ;

this.label1.Location = new System.Drawing.Point ( 56 , 24 ) ;

this.label1.Name = "label1" ;

this.label1.Size = new System.Drawing.Size ( 88 , 16 ) ;

this.label1.TabIndex = 5 ;

this.label1.Text = "注册手机号:" ;

this.label2.Location = new System.Drawing.Point ( 88 , 77 ) ;

this.label2.Name = "label2" ;

this.label2.Size = new System.Drawing.Size ( 72 , 16 ) ;

this.label2.TabIndex = 6 ;

this.label2.Text = "口令:" ;

this.label3.Location = new System.Drawing.Point ( 56 , 128 ) ;

this.label3.Name = "label3" ;

this.label3.Size = new System.Drawing.Size ( 96 , 16 ) ;

this.label3.TabIndex = 7 ;

this.label3.Text = "目标手机号:" ;

this.label4.Location = new System.Drawing.Point ( 96 , 176 ) ;

this.label4.Name = "label4" ;

this.label4.Size = new System.Drawing.Size ( 72 , 16 ) ;

this.label4.TabIndex = 8 ;

this.label4.Text = "内容:" ;

this.textBox4.Location = new System.Drawing.Point ( 144 , 175 ) ;

this.textBox4.Multiline = true ;

this.textBox4.Name = "textBox4" ;

this.textBox4.Size = new System.Drawing.Size ( 184 , 48 ) ;

this.textBox4.TabIndex = 3 ;

this.textBox4.Text = "" ;

this.AutoScaleBaseSize = new System.Drawing.Size ( 6 , 14 ) ;

this.ClientSize = new System.Drawing.Size ( 410 , 303 ) ;

this.Controls.Add ( this.button1 ) ;

this.Controls.Add ( this.textBox4 ) ;

this.Controls.Add ( this.textBox3 ) ;

this.Controls.Add ( this.textBox2 ) ;

this.Controls.Add ( this.textBox1 ) ;

this.Controls.Add ( this.label4 ) ;

this.Controls.Add ( this.label3 ) ;

this.Controls.Add ( this.label2 ) ;

this.Controls.Add ( this.label1 ) ;

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle ;

this.MaximizeBox = false ;

this.Name = "Form1" ;

this.Text = "Visual C#实现短信发送" ;

this.ResumeLayout ( false ) ;

}

请问VB.NET 如何利用PostMessage 向窗口的指定Edit发送信息

你不用程序的情况能不能用TAB切换焦点。如果这样不行的话你用程序控件是没用的。

或都直接对第二个编辑框发送消息。

C#/VB.NET中 UDP协议连接服务器问题...运行没出错..但是收不到信息.

服务器先进行

Bind ()绑定服务器的端口

然后BeginReceive接受客户端发送的数据

客户端Bind ()绑定客户端接受和发送数据的端口

SendTo()来发送数据就可以

不需要进行BeginConnect,因为UDP不需要连接

用vb.net实现网络通信

用 vb.net socket通信

Dim th As Threading.Thread

2 Dim tcpl As System.Net.Sockets.TcpListener

3

4 Private Sub Form1_Load()Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

5 th = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf MyListen))

6 th.Start()

7 End Sub

8

9 Public Sub SendMessage()Sub SendMessage(ByVal IP As String, ByVal SendMsg As String)

10 Try

11 If IP "" Then

12 Dim tcpc As New System.Net.Sockets.TcpClient(IP, 5656)

13 Dim tcpStream As Net.Sockets.NetworkStream = tcpc.GetStream

14 Dim reqStream As New IO.StreamWriter(tcpStream)

15 reqStream.Write(SendMsg)

16 reqStream.Flush()

17 tcpStream.Close()

18 tcpc.Close()

19 End If

20 Catch ex As Exception

21 MsgBox(ex.Message.ToString)

22 End Try

23 End Sub

24 Private Sub MyListen()Sub MyListen()

25 Try

26 Dim ipAddress As System.Net.IPAddress = System.Net.Dns.Resolve(System.Net.Dns.GetHostName).AddressList(0)

27 tcpl = New System.Net.Sockets.TcpListener(ipAddress, 5656)

28 tcpl.Start()

29 While True

30 Dim s As System.Net.Sockets.Socket = tcpl.AcceptSocket()

31 Dim MyBuffer(1024) As Byte

32 Dim i As Integer

33 i = s.Receive(MyBuffer)

34 If i 0 Then

35 Dim lstrRec As String

36 Dim j As Integer

37 For j = 0 To i - 1

38 TextBox1.Text += Chr(MyBuffer(j)) ","

39 Next

40 End If

41 End While

42 Catch ex As Exception

43 MsgBox(ex.Message.ToString)

44 End Try

45 End Sub

46

47 Private Sub Button1_Click()Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

48 SendMessage("192.168.0.61", TextBox2.Text)

49 End Sub


当前文章:vb.net手机短信 c#短信
URL链接:http://cxhlcq.com/article/dohhsch.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部