2017-05-24 92 views

回答

0

有关当前用户连接的所有RDP环境变量的列表,请参阅下面的注释。

针对Citrix ICA连接的REG位置HKEY_LOCAL_MACHINE \ SOFTWARE \思杰\伊卡\会议\\连接\

的子项ClientProductID和ClientType会给参照什么样的设备被连接。

下面是一些基本代码来获得远程会话,然后从注册表获取会话信息。

// Prints out ICA or RDP session ID of current user & gets ICA session ClientType variable 

using System; 
using Microsoft.Win32; 

namespace ViaRegedit 
{ 
    class Program03 
    { 
     static void Main(string[] args) 
     { 
      // Obtain an instance of RegistryKey for the CurrentUser registry 
      RegistryKey rkCurrentUser = Registry.CurrentUser; 
      // Obtain the test key (read-only) and display it. 
      RegistryKey rkTest = rkCurrentUser.OpenSubKey("Remote"); 

      foreach (string valueName in rkTest.GetSubKeyNames()) 
      { 
       //Getting path to RDP/Citrix session ID 
       string RDPICApath = ""; 
       if (rkTest.OpenSubKey(valueName) != null && rkTest.OpenSubKey(valueName) != null) { RDPICApath = rkTest.OpenSubKey(valueName).ToString(); } 
       Console.WriteLine("Getting CurrentUser ICA-RDP path from string = " + RDPICApath); 

       //List<string> RDPICAnumber = RDPICApath.Split('\\').ToList(); 
       string RDPICAnumber = RDPICApath.Substring(RDPICApath.LastIndexOf('\\') + 1); 
       Console.WriteLine("Current User RDPICAnumber = " + RDPICAnumber); 

       //Getting reg local machine info for Citrix based on RDP/Citrix session ID "RDPICAnumber" 
       string regLocal = @"SOFTWARE\Citrix\Ica\Session\" + RDPICAnumber + @"\Connection"; 
       RegistryKey localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64); 
       RegistryKey citrixKey = localKey.OpenSubKey(regLocal); 
       Console.WriteLine("Registry " + citrixKey + " Does Exist - going to get ClientType"); 
       //getting clietAddress var from citrixKey 
       string clientType = ""; 
       if (citrixKey != null && citrixKey.GetValue("clientType") != null) 
        {clientType = citrixKey.GetValue("ClientType").ToString();} 
        Console.WriteLine("Getting current user clientType from string = " + clientType); 
      } 
      rkTest.Close(); 
      rkCurrentUser.Close(); 
      Console.ReadLine(); 
     } 
    } 

} 

你可以很容易地更换ClientProductID和clientType使用以下基准获得ClientProductID information.

enter image description here

+0

THX,但使用的是Windows服务器2016年,而不是Citrix服务器我真的。 –

+0

你好。有关当前用户连接的所有RDP环境变量的列表,请参阅以下命令。如果在操作系统和CLIENTNAME上查找操作系统类型或连接设备焦点,但在移动/ Windows RDP连接之间建议检查打印输出的任何差异。 (foreach)(DictionaryEntry de in Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Process)) { string log =“\ r \ n”+ de.Key +“=”+ de.Value; Console.WriteLine(“{0} = {1}”,de.Key,de.Value); }' – BrettKennard

+0

你好,我检查了所有的EnvironmentVariables。但我总是从WindowsServer会话中获取信息,而不是从实际客户端获取信息。 OS = Windows_NT CLIENTNAME不适合我。 –