📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace 实现通讯信使
{
public partial class Form1 : Form
{
[DllImport("Netapi32", CharSet = CharSet.Unicode)]
public static extern int NetMessageBufferSend(
string servername, //服务器名称,为NULL
string fromname, //接收方名称,可为IP或计算机名称
string msgname, //信息名称,为NULL
string buf, //信息
int buflen); //信息长度
public Form1()
{
InitializeComponent();
}
private void but_send_Click(object sender, EventArgs e)
{
try
{
this.timer1.Enabled = true;
byte[] bBuffer = System.Text.Encoding.Unicode.GetBytes(txt_Details.Text);
int nRet = NetMessageBufferSend(null, txt_server.Text, null, txt_Details.Text, txt_Details.Text.Length * 2 + 2);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void timer1_Tick(object sender, EventArgs e)
{
but_send_Click(sender,e);
}
private void button1_Click(object sender, EventArgs e)
{
this.timer1.Enabled = false ;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -