OSDN Git Service

#39608 [DTXC] 64bit OS環境で、オプションダイアログを開こうとすると例外が発生する問題を修正。
[dtxmania/dtxmania.git] / DTXCreator / コード / 00.全体 / Program.cs
index ae3474f..c722b27 100644 (file)
@@ -2,12 +2,17 @@
 using System.Collections.Generic;
 using System.Globalization;
 using System.Threading;
+using System.IO;
+using System.Runtime.InteropServices;
 using System.Windows.Forms;
 
 namespace DTXCreator
 {
        internal static class Program
        {
+               [DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)]
+               internal static extern bool SetDllDirectory(string lpPathName);
+
                [STAThread]
                private static void Main()
                {
@@ -18,6 +23,18 @@ namespace DTXCreator
                        Thread.CurrentThread.CurrentCulture = new CultureInfo( "de-DE", false );        // yyagi; For testing decimal point in German resources
 #endif
 #endif
+                       string path = Path.GetDirectoryName(Application.ExecutablePath);
+
+                       SetDllDirectory(null);
+                       if (Environment.Is64BitProcess)
+                       {
+                               SetDllDirectory(Path.Combine(path, @"dll\x64"));
+                       }
+                       else
+                       {
+                               SetDllDirectory(Path.Combine(path, @"dll"));
+                       }
+
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault( false );
                        Application.Run( new Cメインフォーム() );