我想用c#来识别我的网络中的工作站,有什么方法可以用c#来检索它。在网络c中识别工作站#
我使用下面的代码:
[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);
}
}
如何区分正常的计算机和工作站的网络? – Arshad