扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:阿虎 来源:天极开发 2007年11月12日
关键字:
using System ; using System.Drawing ; using System.Collections ; using System.ComponentModel ; using System.Windows.Forms ; using System.Data ; using System.Runtime.InteropServices ; //申明WinAPI函数需要使用到此命名空间 |
private void InitializeComponent ( ) { this.textBox1 = new System.Windows.Forms.TextBox ( ) ; this.textBox2 = 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.SuspendLayout ( ) ; this.textBox1.Location = new System.Drawing.Point ( 124 , 58 ) ; this.textBox1.Name = "textBox1" ; this.textBox1.Size = new System.Drawing.Size ( 212 , 21 ) ; this.textBox1.TabIndex = 0 ; this.textBox1.Text = "" ; this.textBox2.Location = new System.Drawing.Point ( 124 , 126 ) ; this.textBox2.Multiline = true ; this.textBox2.Name = "textBox2" ; this.textBox2.Size = new System.Drawing.Size ( 212 , 82 ) ; this.textBox2.TabIndex = 1 ; this.textBox2.Text = "" ; this.button1.Location = new System.Drawing.Point ( 122 , 232 ) ; this.button1.Name = "button1" ; this.button1.Size = new System.Drawing.Size ( 106 , 36 ) ; this.button1.TabIndex = 3 ; this.button1.Text = "发送" ; this.button1.Click += new System.EventHandler ( this.button1_Click ) ; this.label1.Location = new System.Drawing.Point ( 8 , 66 ) ; this.label1.Name = "label1" ; this.label1.Size = new System.Drawing.Size ( 132 , 23 ) ; this.label1.TabIndex = 4 ; this.label1.Text = "IP地址或计算机名:" ; this.label2.Location = new System.Drawing.Point ( 78 , 134 ) ; this.label2.Name = "label2" ; this.label2.Size = new System.Drawing.Size ( 46 , 23 ) ; this.label2.TabIndex = 5 ; this.label2.Text = "内容:" ; this.AutoScaleBaseSize = new System.Drawing.Size ( 6 , 14 ) ; this.ClientSize = new System.Drawing.Size ( 356 , 297 ) ; this.Controls.Add ( this.button1 ) ; this.Controls.Add ( this.textBox2 ) ; this.Controls.Add ( this.textBox1 ) ; 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 ) ; } |
图04:【Visual C#实现通讯信使】项目的设计界面 |
private void button1_Click ( object sender , System.EventArgs e ) { byte [ ] bBuffer = System.Text.Encoding.Unicode.GetBytes ( textBox2.Text ); int nRet = NetMessageBufferSend ( null , textBox1.Text , null , textBox2.Text , textBox2.Text.Length * 2 + 2 ) ; } |
[DllImport ( "Netapi32" , CharSet = CharSet.Unicode ) ] public static extern int NetMessageBufferSend ( string servername , //服务器名称,为NULL string fromname , //接收方名称,可为IP或计算机名称 string msgname , //信息名称,为NULL string buf , //信息 int buflen ) ; //信息长度 |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者