By default, the Messenger Service of WINXP SP2 is forbidden. to use it, you must first start the service.
// Send a message
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 ("the message has been sent to" + strip + ". ")! =-1)
{
Lb_info.items.add (datetime. Now. tolongtimestring () + "send message to" + strhostname + ":" + strmsg );
}
Else
{
Lb_info.items.add ("sending message to" + strhostname + "failed! "+ Datetime. Now. tolongtimestring ());
}
}
Catch (exception ex)
{
Lb_info.items.add (ex. Message + datetime. Now. tolongtimestring () + "send message to" + strhostname + "failed! ");
}
}