2017-05-24 2 views
0

私のアプリケーションはRDP経由でWindows Server上で実行されています。アプリケーションでは、クライアント(RDPセッションを持つ)がモバイルデバイスであるかどうかを知りたいと思います。C#リモートデスクトップ:クライアントデバイスまたはクライアントオペレーティングシステムを知りたい

クライアントオペレーティングシステムを入手できますか?

答えて

0

接続している現在のユーザーのすべてのRDP環境変数の一覧については、下記のコメントを参照してください。

のCitrix ICA接続のためのREGの場所は、サブキーClientProductIDとのClientTypeが接続されているデバイスの種類への参照を与える

\ HKEY_LOCAL_MACHINE \ SOFTWARE \ Citrixの\イカ\セッション\\接続です。

ここでは、リモートセッションを取得し、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でクライアントタイプを交換し、ClientProductID information.

enter image description here

+0

Thxをを取得し、次の参照を使用していますが、I'mは、Windows Server 2016、ないCitrixサーバーを使用できます。 –

+0

こんにちは。接続している現在のユーザーのすべてのRDP環境変数の一覧については、次のコマンドを参照してください。 osタイプを探したり、OSとCLIENTNAMEにデバイスのフォーカスを接続しても、出力の違いがないかどうかは、Mobile/Windows RDP接続の間で確認してください。 'foreach(Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Process)のDictionaryEntry de) { 文字列ログ=" \ r \ n "+ de.Key +" = "+ de.Value; Console.WriteLine( "{0} = {1}"、de.Key、de.Value); } ' – BrettKennard

+0

こんにちは、私はすべてのEnvironmentVariablesをチェックしました。しかし、私はいつもReal-ClientからではなくWindowsServer SessionからInfosを入手します。 OS = Windows_NT CLIENTNAMEは私のために働いていません。 –

関連する問題