默认情况下,WinXP SP2的Messenger服务是禁止的,如果需要使用必须先启动该服务。

        //发消息
        private void NetSendMsg(string strIp, string strHostname, string strMsg)
        {
            try
            {
                Process sendprocess =new  Process();
                sendprocess.StartInfo.FileName = "net.exe";
                sendprocess.StartInfo.Arguments = "send " + strIp + " " + strMsg;
                sendprocess.StartInfo.UseShellExecute = false;
                sendprocess.StartInfo.RedirectStandardOutput = true;
                sendprocess.StartInfo.RedirectStandardError = true;
                sendprocess.StartInfo.CreateNoWindow = true;
                sendprocess.Start();

                string strSend = sendprocess.StandardOutput.ReadToEnd();

                if (strSend.IndexOf("消息已经送到 "+strIp+"。") != -1)
                {
                    lb_Info.Items.Add(DateTime.Now.ToLongTimeString() + "发消息到 " + strHostname + ":" + strMsg);
                }
                else
                {
                    lb_Info.Items.Add("发消息到" + strHostname + "失败!"+DateTime.Now.ToLongTimeString());
                }
               
            }
            catch(Exception ex)
            {
                lb_Info.Items.Add(ex.Message+DateTime.Now.ToLongTimeString()+"发消息到" + strHostname + "失败!");
            }
        }

相关文章:

  • 2022-01-18
  • 2021-10-01
  • 2022-12-23
  • 2021-12-02
  • 2021-08-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-06
  • 2021-06-03
  • 2021-12-02
  • 2022-02-23
  • 2021-06-08
  • 2021-11-28
相关资源
相似解决方案