2017-05-24 91 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不適合我。 –