3 回答
TA贡献1998条经验 获得超6个赞
如果您不想自己处理P / Invokes,另一种选择是使用Cassia库:
using System;
using System.Security.Principal;
using Cassia;
namespace CassiaSample
{
public static class Program
{
public static void Main(string[] args)
{
ITerminalServicesManager manager = new TerminalServicesManager();
using (ITerminalServer server = manager.GetRemoteServer("your-server-name"))
{
server.Open();
foreach (ITerminalServicesSession session in server.GetSessions())
{
NTAccount account = session.UserAccount;
if (account != null)
{
Console.WriteLine(account);
}
}
}
}
}
}
- 3 回答
- 0 关注
- 562 浏览
添加回答
举报