zoukankan      html  css  js  c++  java
  • C#调用net.exe发送消息

    默认情况下,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 + "失败!");
                }
            }

  • 相关阅读:
    bootstrap不同屏幕区分数值
    jq星星评分
    大話西遊
    HDU 5353 Average 贪心
    HDU 5358 First One 数学+尺取法
    生活感受
    HDU 4372 Count the Buildings 组合数学
    暑假集训-合训第九场
    一些资料
    多校-HDU 5351 MZL's Border 数学规律
  • 原文地址:https://www.cnblogs.com/mossan/p/749664.html
Copyright © 2011-2022 走看看