C#远程桌面:想要了解客户端设备或客户端操作系统

时间:2017-05-24 14:40:34

标签: c# windows mobile rdp

我的应用程序通过RDP在Windows Server上运行。在应用程序中我想知道客户端(使用RDP会话)是否是移动设备。

是否可以获得客户端操作系统?

2 个答案:

答案 0 :(得分:0)

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

Citrix ICA连接的注册位置为HKEY_LOCAL_MACHINE \ SOFTWARE \ Citrix \ Ica \ Session \\ Connection \

Subkeys ClientProductID和ClientType将引用要连接的设备类型。

以下是获取远程会话然后从regedit获取会话信息的一些基本代码。

  // 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

答案 1 :(得分:0)

我正面临着同样的问题。我尝试从WTSQuerySessionInformation Win32 API函数读取WTSClientProductId值,但即使从Android平板电脑启动的会话中调用它,它也始终返回0x0001。