1
// ------------------------------------------------------------------
2 // Copyright (C) 2011-2014 Maruko Toolbox Project
4 // Authors: komaruchan <sandy_0308@hotmail.com>
5 // LunarShaddow <aflyhorse@hotmail.com>
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 // -------------------------------------------------------------------
23 using System
.Collections
.Generic
;
24 using System
.Configuration
;
25 using System
.Diagnostics
;
27 using System
.Reflection
;
28 using System
.Runtime
.InteropServices
;
29 using System
.Threading
;
30 using System
.Windows
.Forms
;
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");
44 path
= Path
.Combine(path
, "x64");
45 if (!SetDllDirectory(path
))
46 throw new System
.ComponentModel
.Win32Exception();
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)
65 // MessageBox.Show("你已经打开了一个小丸工具箱喔!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
66 // Application.Exit();
70 if (ConfigurationManager
.AppSettings
["SplashScreen"] == "True")
72 Application
.Run(new mycontext());
76 Application
.Run(new MainForm());