Remove the limit of running multiple instance.
[marukotoolbox.git] / mp4box / Program.cs
blob57b7c44659b44ede4481be44af7961f494c475c3
1 // ------------------------------------------------------------------
2 // Copyright (C) 2011-2014 Maruko Toolbox Project
3 //
4 // Authors: komaruchan <sandy_0308@hotmail.com>
5 // LunarShaddow <aflyhorse@hotmail.com>
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
16 // express or implied.
17 // See the License for the specific language governing permissions
18 // and limitations under the License.
19 // -------------------------------------------------------------------
22 using System;
23 using System.Collections.Generic;
24 using System.Configuration;
25 using System.Diagnostics;
26 using System.IO;
27 using System.Reflection;
28 using System.Runtime.InteropServices;
29 using System.Threading;
30 using System.Windows.Forms;
31 namespace mp4box
33 static class Program
35 private class NativeMethods
37 [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
38 public static extern bool SetDllDirectory(string path);
40 public static void SetUnmanagedDllDirectory()
42 string path = Path.Combine(Application.StartupPath, "tools");
43 if (IntPtr.Size == 8)
44 path = Path.Combine(path, "x64");
45 if (!SetDllDirectory(path))
46 throw new System.ComponentModel.Win32Exception();
50 /// <summary>
51 /// 应用程序的主入口点。
52 /// </summary>
53 [STAThread]
54 static void Main()
56 Application.EnableVisualStyles();
57 Application.SetCompatibleTextRenderingDefault(false);
58 NativeMethods.SetUnmanagedDllDirectory();
60 // var modulename = Process.GetCurrentProcess().MainModule.ModuleName;
61 // var procesname = Path.GetFileNameWithoutExtension(modulename);
62 // Process[] processes = Process.GetProcessesByName(procesname);
63 // if (processes.Length > 1)
64 // {
65 // MessageBox.Show("你已经打开了一个小丸工具箱喔!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
66 // Application.Exit();
67 // return;
68 // }
70 if (ConfigurationManager.AppSettings["SplashScreen"] == "True")
72 Application.Run(new mycontext());
74 else
76 Application.Run(new MainForm());