-// Copyright (C) 2013 Kazuhiro Fujieda <fujieda@users.sourceforge.jp>\r
+// Copyright (C) 2013, 2014 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
// \r
-// This program is part of KancolleSniffer.\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
//\r
-// KancolleSniffer is free software: you can redistribute it and/or modify\r
-// it under the terms of the GNU General Public License as published by\r
-// the Free Software Foundation, either version 3 of the License, or\r
-// (at your option) any later version.\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
//\r
-// This program is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-// GNU General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with this program; if not, see <http://www.gnu.org/licenses/>.\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
\r
using System;\r
-using System.Diagnostics;\r
-using System.Runtime.InteropServices;\r
using System.Windows.Forms;\r
\r
namespace KancolleSniffer\r
{\r
internal static class Program\r
{\r
- /// <summary>\r
- /// アプリケーションのメイン エントリ ポイントです。\r
- /// </summary>\r
[STAThread]\r
private static void Main()\r
{\r
Application.Run(new MainForm());\r
}\r
}\r
-\r
- /// <summary>\r
- /// Win32APIを実行するクラス\r
- /// </summary>\r
- public class Win32API\r
- {\r
- [DllImport("user32.dll")]\r
- private static extern bool SetForegroundWindow(IntPtr hWnd);\r
-\r
- [DllImport("user32.dll")]\r
- private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);\r
-\r
- [DllImport("user32.dll")]\r
- private static extern bool IsIconic(IntPtr hWnd);\r
-\r
- /// <summary>\r
- /// 同じアプリケーションがすでに起動しているか調べる。起動していたら最前面に表示する。\r
- /// </summary>\r
- /// <returns>起動していたらtrue</returns>\r
- public static bool ProcessAlreadyExists()\r
- {\r
- var cur = Process.GetCurrentProcess();\r
- var all = Process.GetProcessesByName(cur.ProcessName);\r
- foreach (var p in all)\r
- {\r
- if (cur.Id == p.Id)\r
- continue;\r
- if (p.MainModule.FileName != cur.MainModule.FileName)\r
- continue;\r
- if (IsIconic(p.MainWindowHandle))\r
- ShowWindowAsync(p.MainWindowHandle, 9); // SW_RESTORE\r
- else\r
- SetForegroundWindow(p.MainWindowHandle);\r
- return true;\r
- }\r
- return false;\r
- }\r
- }\r
}
\ No newline at end of file