 |
|
 |
| |
Developer on focus
Anton Zamov is a dipl. engineer with more than 6 years of active professional
experience and many awards ...
read more>>
|
|
 |
 |
 |
|
 |
|
 |
| |
|
How to send \" NET SEND \" messages ( Windows 2000 & Windows XP only )?
|
Have you ever send messages to the local network using the command promt and the well known command "net send"?.<br>
The 2 methods listed below allows you to make exactly the same thing from your C# application.
protected string name="";
protected string sysname="";
public void NetSend(string mname,string strMessage)
{
/*
This method is created by Anton Zamov.
web site: http://zamov.online.fr
Feel free to use and redistribute this method
in condition that you keep this message intact.
*/
this.sysname=mname;
this.strMessage = strMessage;
ThreadStart tStart = new ThreadStart(this.SendMessageThread);
Thread senderThread = new Thread(tStart);
senderThread.Start();
}
public void SendMessageThread()
{
/*
This method is created by Anton Zamov.
web site: http://zamov.online.fr
Feel free to use and redistribute this method
in condition that you keep this message intact.
*/
try
{
string strLine = "net send " + sysname + " " +
this.strMessage + " > C:\\\\netsend.log";
FileStream fs = new FileStream("c:\\\\netsend.bat" ,
FileMode.Create,
FileAccess.Write);
StreamWriter streamWriter = new StreamWriter(fs);
streamWriter.BaseStream.Seek(0, SeekOrigin.End);
streamWriter.Write(strLine);
streamWriter.Flush();
streamWriter.Close();
fs.Close();
Process p = new Process();
p.StartInfo.FileName = "C:\\\\netsend.bat";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
p.Close();
FileStream fsOutput = new FileStream("C:\\\\netsend.log",
FileMode.Open ,
FileAccess.Read);
StreamReader reader = new StreamReader(fsOutput);
reader.BaseStream.Seek(0,SeekOrigin.Begin);
string strOut = reader.ReadLine();
reader.Close();
fsOutput.Close();
}
catch(Exception)
{
// TODO
}
}
|
About the author of this programming example or tutorial:
Anton Zamov is a software engineer with more than6 years
of active experience in web and software development and design.
Anton Zamov has extensive experience and broad knowledgebase
in C# and JAVA programming and has created a lot of
running e-commerce systems, portals and content management
systems using PHP and other web development technologies.
For more information about Anton Zamov, you may visit the personal web site of
Anton Zamov.
|
|
|
 |
 |
 |
|
|