Managed API for "NET SEND"

  • Thread starter Thread starter Guest
  • Start date Start date
Hi Daniel.

Not sure about a managed version, but you can use interop ala this:

using System.Runtime.InteropServices;

public class NetMessage
{
public static void Test()
{
NetMessage.Send("morten", "morten", "message from user");
NetMessage.Send("morten", "message from machine");
}

public static void Send(string to, string message)
{
Send(to, null, message);
}

public static void Send(string to, string from, string message)
{
byte[] buf = System.Text.Encoding.Unicode.GetBytes(message);

int err = NetMessageBufferSend(null, to, from, buf, buf.Length);

if ( err != 0 )
throw new System.ComponentModel.Win32Exception( err );
}

[DllImport("Netapi32", CharSet=CharSet.Unicode)]
private static extern int NetMessageBufferSend(
string servername,
string msgname,
string fromname,
byte[] buf,
int buflen);
}

Morten
 
Back
Top