i am trying to identify the workstations in my network using c#, what are the possible ways to retrieve it using c#.
i am using following code :
[DllImport("Netapi32.dll")]
static extern unsafe int NetWkstaGetInfo(IntPtr servername, int level, byte** bufptr);
[DllImport("Netapi32.dll")]
static extern unsafe int NetApiBufferFree(byte* bufptr);
[STAThread]
static unsafe void Main(string[] args)
{
byte* bp = null;
int rc = NetWkstaGetInfo(IntPtr.Zero, 102, &bp);
WkstaInfo102* wip = (WkstaInfo102*)bp;
Console.WriteLine("System {0} has {1} users logged on", Marshal.PtrToStringAuto(wip->computername), wip->logged_on_users);
rc = NetApiBufferFree(bp);
}
}