OSDN Git Service

OpenTweenを管理者権限で起動した場合に警告を表示する
authorKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Mar 2017 03:48:34 +0000 (12:48 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Mar 2017 04:28:17 +0000 (13:28 +0900)
OpenTween/ApplicationEvents.cs
OpenTween/Properties/Resources.Designer.cs
OpenTween/Properties/Resources.en.resx
OpenTween/Properties/Resources.resx
OpenTween/Resources/ChangeLog.txt

index c52ba5e..3e6cb2b 100644 (file)
@@ -38,6 +38,7 @@ using System.Globalization;
 using System.Reflection;
 using Microsoft.Win32;
 using OpenTween.Setting;
+using System.Security.Principal;
 
 namespace OpenTween
 {
@@ -60,6 +61,8 @@ namespace OpenTween
         [STAThread]
         static int Main(string[] args)
         {
+            WarnIfRunAsAdministrator();
+
             if (!CheckRuntimeVersion())
             {
                 var message = string.Format(Properties.Resources.CheckRuntimeVersion_Error, ".NET Framework 4.5.1");
@@ -108,6 +111,22 @@ namespace OpenTween
         }
 
         /// <summary>
+        /// OpenTween が管理者権限で実行されている場合に警告を表示します
+        /// </summary>
+        private static void WarnIfRunAsAdministrator()
+        {
+            using (var currentIdentity = WindowsIdentity.GetCurrent())
+            {
+                var principal = new WindowsPrincipal(currentIdentity);
+                if (principal.IsInRole(WindowsBuiltInRole.Administrator))
+                {
+                    var message = string.Format(Properties.Resources.WarnIfRunAsAdministrator_Message, Application.ProductName);
+                    MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                }
+            }
+        }
+
+        /// <summary>
         /// 動作中の .NET Framework のバージョンが適切かチェックします
         /// </summary>
         private static bool CheckRuntimeVersion()
index 1b335ab..a211351 100644 (file)
@@ -3272,6 +3272,19 @@ namespace OpenTween.Properties {
         }
         
         /// <summary>
+        ///   {0}を管理者権限で実行する事は推奨されません。
+        ///
+        /// * {0}は管理者権限を必要とするソフトウェアではありません。
+        /// * 管理者権限で実行するとD&amp;Dで画像を投稿する操作が制限されます。
+        /// * {0}の設定ファイルが一般ユーザー権限で編集できなくなります。 に類似しているローカライズされた文字列を検索します。
+        /// </summary>
+        internal static string WarnIfRunAsAdministrator_Message {
+            get {
+                return ResourceManager.GetString("WarnIfRunAsAdministrator_Message", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   はい に類似しているローカライズされた文字列を検索します。
         /// </summary>
         internal static string Yes {
index a1ee30f..0caaa46 100644 (file)
@@ -1148,4 +1148,11 @@ Do you retry to update status?</value>
 Existing setting files are copied to {1}.
 (The setting files in {1} will be used at next startup)</value>
   </data>
+  <data name="WarnIfRunAsAdministrator_Message" xml:space="preserve">
+    <value>It is not recommended to run {0} as administrator.
+
+ * {0} does not require administrator privileges.
+ * If you run as administrator, operations to post images with D&amp;D will be restricted.
+ * After running, the setting files of {0} will be able to modify only from administrator.</value>
+  </data>
 </root>
\ No newline at end of file
index d776872..612c2cf 100644 (file)
 既存の設定ファイルは {1} にコピーされます。
 (次回起動時は {1} の設定ファイルが優先されます)</value>
   </data>
+  <data name="WarnIfRunAsAdministrator_Message" xml:space="preserve">
+    <value>{0}を管理者権限で実行する事は推奨されません。
+
+ * {0}は管理者権限を必要とするソフトウェアではありません。
+ * 管理者権限で実行するとD&amp;Dで画像を投稿する操作が制限されます。
+ * {0}の設定ファイルが一般ユーザー権限で編集できなくなります。</value>
+  </data>
 </root>
\ No newline at end of file
index a101736..4798bb1 100644 (file)
@@ -9,6 +9,9 @@
  * CHG: OpenTweenを書き込みに制限のあるフォルダ (Program Files など) に配置した場合、設定ファイルを C:\Users\ユーザー名\Roaming\OpenTween\ 以下に保存します
   - 書き込み可能なフォルダ内に配置した場合は、今まで通り OpenTween.exe と同じ場所に保存します
   - OpenTweenを Program Files 内に配置した状態での使用は現時点ではあくまで非推奨です
+ * CHG; OpenTweenを管理者権限で起動しようとすると警告が表示されるようになります
+  - OpenTweenは管理者権限を必要とするソフトウェアではありません
+  - 管理者権限でOpenTweenを起動する事でD&Dでの画像投稿が制限されたり、設定ファイルが管理者以外から編集できなくなる場合があります
  * FIX: OSの設定で小数点にピリオド以外の記号を用いている環境で、Foursquareのサムネイル表示時にエラーが発生する不具合を修正 (thx @Xiatian!)
  * FIX: 「前データを取得」の後に通常の更新が行われると、次に「前データを取得」した際に1件も取得されない不具合を修正
  * FIX: 発言一覧の更新時にエラーが発生する不具合を回避