Click here to Skip to main content
16,015,072 members
Home / Discussions / C#
   

C#

 
GeneralEventLog Privileges Pin
Andy *M*24-May-04 22:27
Andy *M*24-May-04 22:27 
GeneralRe: EventLog Privileges Pin
Mazdak24-May-04 23:02
Mazdak24-May-04 23:02 
GeneralRe: EventLog Privileges Pin
Andy *M*24-May-04 23:12
Andy *M*24-May-04 23:12 
GeneralRe: EventLog Privileges Pin
Dave Kreskowiak25-May-04 2:28
mveDave Kreskowiak25-May-04 2:28 
Questionhow to netsend to wan locations Pin
skooij24-May-04 20:12
skooij24-May-04 20:12 
AnswerRe: how to netsend to wan locations Pin
Dave Kreskowiak25-May-04 2:22
mveDave Kreskowiak25-May-04 2:22 
GeneralRe: how to netsend to wan locations Pin
skooij25-May-04 3:00
skooij25-May-04 3:00 
GeneralRe: how to netsend to wan locations Pin
Heath Stewart25-May-04 3:27
protectorHeath Stewart25-May-04 3:27 
It really doesn't matter how it's done. You can use the System.Diagnostics.Process class to do this programmatically, as we've discussed before in this forum:
string myDomainName = Environment.UserDomainName;
string theMessage = "This is a test.";
Process.Start("net.exe", string.Format("send * /domain:{0} {1}",
  myDomainName, theMessage));
If you want a "better" way, you can encapsulate the NetMessageBufferSend API using P/Invoke:
public sealed class NetSend
{
  public NetSend() {}
  // Define fields and properties to get/set those fields.
 
  public Send()
  {
    // Only works in Windows NT-based OSes.
    if (Environment.OSVersion.Platform == PlatformID.Win32Windows)
      throw new NotSupportException();
 
    // Alloc your buffers using the NetApiBufferAllocate API, send
    // your message and free the string buffer.
  }
  [DllImport("netapi32.dll", CharSet=CharSet.Unicode)]
  private static extern uint NetMessageBufferSend(
    string servername, // null is local machine
    string msgalias,
    string fromname,
    byte[] msg,
    uint msglen);
  [DllImport("netapi32.dll")]
  private static extern uint NetApiBufferAllocate(
    uint byteCount,
    out IntPtr ptr);
  [DllImport("netapi32.dll")]
  private static extern uint NetApiBufferFree(
    IntPtr ptr);
}
See the documentation for the NetMessageBufferSend API on MSDN[^] or you could try searching this forum of the CodeProject site for existing examples.

 

Microsoft MVP, Visual C#
My Articles
GeneralRelease vs. debug Pin
spif200124-May-04 19:58
spif200124-May-04 19:58 
GeneralRe: Release vs. debug Pin
Andy *M*24-May-04 22:34
Andy *M*24-May-04 22:34 
GeneralRe: Release vs. debug Pin
spif200124-May-04 23:23
spif200124-May-04 23:23 
GeneralRe: Release vs. debug Pin
Dave Kreskowiak25-May-04 2:16
mveDave Kreskowiak25-May-04 2:16 
GeneralRe: Release vs. debug Pin
spif200125-May-04 2:24
spif200125-May-04 2:24 
GeneralRe: Release vs. debug Pin
Heath Stewart25-May-04 3:05
protectorHeath Stewart25-May-04 3:05 
GeneralRe: Release vs. debug Pin
spif200125-May-04 20:39
spif200125-May-04 20:39 
GeneralRe: Release vs. debug Pin
spif200125-May-04 21:18
spif200125-May-04 21:18 
GeneralData Binding a TextBox to a DataSet Pin
woaksie24-May-04 18:49
woaksie24-May-04 18:49 
GeneralRe: Data Binding a TextBox to a DataSet Pin
Heath Stewart25-May-04 2:50
protectorHeath Stewart25-May-04 2:50 
GeneralRe: Data Binding a TextBox to a DataSet Pin
woaksie25-May-04 4:54
woaksie25-May-04 4:54 
GeneralRe: Data Binding a TextBox to a DataSet Pin
Heath Stewart25-May-04 5:51
protectorHeath Stewart25-May-04 5:51 
GeneralRe: Data Binding a TextBox to a DataSet Pin
woaksie25-May-04 19:06
woaksie25-May-04 19:06 
GeneralRe: Data Binding a TextBox to a DataSet Pin
woaksie25-May-04 19:21
woaksie25-May-04 19:21 
GeneralExpressions(calculations) Pin
stevemasters2224-May-04 18:46
stevemasters2224-May-04 18:46 
GeneralRe: Expressions(calculations) Pin
sreejith ss nair24-May-04 19:20
sreejith ss nair24-May-04 19:20 
GeneralRe: Expressions(calculations) Pin
stevemasters2224-May-04 19:34
stevemasters2224-May-04 19:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.