c#如何在Windows 2008R2中为终端会话分配虚拟IP

c#如何在Windows 2008R2中为终端会话分配虚拟IP,c#,networking,C#,Networking,我的Windows 2008 R2服务器已启用终端服务的IP虚拟化。我需要知道在我的程序中,哪个虚拟IP被分配给我运行程序的会话 现在,当我获得IP地址时: String strHostName = Dns.GetHostName(); IPHostEntry ipEntry = Dns.GetHostByName(strHostName); IPAddress[] addr = ipEntry.AddressList; 我只有服务器的IP,没有为

我的Windows 2008 R2服务器已启用终端服务的IP虚拟化。我需要知道在我的程序中,哪个虚拟IP被分配给我运行程序的会话

现在,当我获得IP地址时:

        String strHostName = Dns.GetHostName();
       IPHostEntry ipEntry = Dns.GetHostByName(strHostName);
        IPAddress[] addr = ipEntry.AddressList;
我只有服务器的IP,没有为会话分配虚拟IP

如何(使用c#)获取此虚拟IP

致以最良好的祝愿, 你可以试试这个

System.Net.IPAddress[] IpAddresses = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName());

for (int i = 0; i < IpAddresses.Length; i++)
{
   Console.WriteLine("IP Address {0}: {1} ", i, IpAddresses[i].ToString());
}
System.Net.IPAddress[]IPAddress=System.Net.Dns.gethostaddress(System.Net.Dns.GetHostName());
for(int i=0;i
使用
WTSQuerySessionInformation

您检查过这个吗?没有,它不工作。它返回服务器的IP,而不是会话的虚拟IP