OSDN Git Service

起動時に .NET Framework のバージョンが適切であるかチェックを行います
authorKimura Youichi <kim.upsilon@bucyou.net>
Sat, 24 May 2014 16:50:58 +0000 (01:50 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 24 May 2014 17:01:56 +0000 (02:01 +0900)
アップデート時に OpenTween.config をコピーし忘れるユーザーが居る可能性を考慮
https://sourceforge.jp/ticket/browse.php?group_id=6526&tid=33868

OpenTween/ApplicationEvents.cs
OpenTween/Properties/Resources.Designer.cs
OpenTween/Properties/Resources.en.resx
OpenTween/Properties/Resources.resx
OpenTween/Resources/ChangeLog.txt

index 0a05836..bfe89c3 100644 (file)
@@ -36,6 +36,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Globalization;
 using System.Reflection;
+using Microsoft.Win32;
 
 namespace OpenTween
 {
@@ -52,6 +53,13 @@ namespace OpenTween
         [STAThread]
         static int Main(string[] args)
         {
+            if (!CheckRuntimeVersion())
+            {
+                var message = string.Format(Properties.Resources.CheckRuntimeVersion_Error, ".NET Framework 4.5.1");
+                MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
+                return 1;
+            }
+
             StartupOptions = ParseArguments(args);
 
             if (!SetConfigDirectoryPath())
@@ -91,6 +99,26 @@ namespace OpenTween
         }
 
         /// <summary>
+        /// 動作中の .NET Framework のバージョンが適切かチェックします
+        /// </summary>
+        private static bool CheckRuntimeVersion()
+        {
+            // Mono 上で動作している場合はバージョンチェックを無視します
+            if (Type.GetType("Mono.Runtime", false) != null)
+                return true;
+
+            // .NET Framework 4.5.1 以降で動作しているかチェックする
+            // 参照: http://msdn.microsoft.com/en-us/library/hh925568%28v=vs.110%29.aspx
+
+            using (var lmKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
+            using (var ndpKey = lmKey.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"))
+            {
+                var releaseKey = (int)ndpKey.GetValue("Release");
+                return releaseKey >= 378675;
+            }
+        }
+
+        /// <summary>
         /// “/key:value”形式の起動オプションを解釈し IDictionary に変換する
         /// </summary>
         /// <remarks>
index a0ab638..2a1dbff 100644 (file)
@@ -728,6 +728,15 @@ namespace OpenTween.Properties {
         }
         
         /// <summary>
+        ///   このソフトウェアは {0} 以降が必要です。 に類似しているローカライズされた文字列を検索します。
+        /// </summary>
+        internal static string CheckRuntimeVersion_Error {
+            get {
+                return ResourceManager.GetString("CheckRuntimeVersion_Error", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   このタブの発言をクリアしてもよろしいですか?{0}(サーバーから発言は削除しません。) に類似しているローカライズされた文字列を検索します。
         /// </summary>
         internal static string ClearTabMenuItem_ClickText1 {
index 591fe68..a483ced 100644 (file)
@@ -1117,4 +1117,7 @@ Available service: {1}</value>
   <data name="UpdateMuteUserIds_Start" xml:space="preserve">
     <value>Getting MuteUserIds...</value>
   </data>
+  <data name="CheckRuntimeVersion_Error" xml:space="preserve">
+    <value>This software requires {0} or later version.</value>
+  </data>
 </root>
\ No newline at end of file
index e866fa1..27717bb 100644 (file)
   <data name="UpdateMuteUserIds_Start" xml:space="preserve">
     <value>MuteUserIds取得中...</value>
   </data>
+  <data name="CheckRuntimeVersion_Error" xml:space="preserve">
+    <value>このソフトウェアは {0} 以降が必要です。</value>
+  </data>
 </root>
\ No newline at end of file
index af1b5be..50a3c55 100644 (file)
@@ -1,6 +1,7 @@
 更新履歴
 
 ==== Ver 1.2.1-beta1(2014/xx/xx)
+ * CHG: 起動時に .NET Framework 4.5.1 以降がインストールされているか確認を行います
  * FIX: 発言詳細欄から右クリックで日本語ハッシュタグを固定すると、エンコード状態のハッシュタグが登録される問題を修正
  * FIX: PublicSearchタブでの検索時に Err:Unauthorized(GetSearch) が表示される問題の回避策を追加
  * FIX: サムネイル画像の読み込み中に別のツイートに選択を移動した際に動作が固まる現象の回避 (thx @_1t_, @Tan90909090, @suzushin!)