简单的消息发送小程序
借用命令行发送消息机制实现,十分简单,废话不说,贴代码吧
using System.Runtime.InteropServices;
public int SendMessage(string sFrom,string sTo,string sMessage)
{
byte[] bBuffer = System.Text.Encoding.Unicode.GetBytes(sMessage);
int nRet = NetMessageBufferSend(null,sTo,sFrom,sMessage,sMessage.Length*2+2);
return nRet;
}
[DllImport ("Netapi32", CharSet=CharSet.Unicode)]
public static extern int NetMessageBufferSend( string servername, string msgname, string fromname, string buf, int buflen);
//调用举例
int a = SendMessage(Request.UserHostName.ToString(),tbx_sendto.Text.Trim(),tbx_message.Value.ToString());
public int SendMessage(string sFrom,string sTo,string sMessage)
{
byte[] bBuffer = System.Text.Encoding.Unicode.GetBytes(sMessage);
int nRet = NetMessageBufferSend(null,sTo,sFrom,sMessage,sMessage.Length*2+2);
return nRet;
}
[DllImport ("Netapi32", CharSet=CharSet.Unicode)]
public static extern int NetMessageBufferSend( string servername, string msgname, string fromname, string buf, int buflen);
//调用举例
int a = SendMessage(Request.UserHostName.ToString(),tbx_sendto.Text.Trim(),tbx_message.Value.ToString());