59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Windows;
|
|
|
|
namespace ConnectPoint
|
|
{
|
|
/// <summary>
|
|
/// App.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class App : Application
|
|
{
|
|
[DllImport("user32", CharSet = CharSet.Unicode)]
|
|
static extern IntPtr FindWindow(string cls, string win);
|
|
[DllImport("user32")]
|
|
static extern IntPtr SetForegroundWindow(IntPtr hWnd);
|
|
[DllImport("user32")]
|
|
static extern bool IsIconic(IntPtr hWnd);
|
|
[DllImport("user32")]
|
|
static extern bool OpenIcon(IntPtr hWnd);
|
|
System.Threading.Mutex mutex;
|
|
|
|
/// <summary>
|
|
/// 程序入口
|
|
/// </summary>
|
|
public App()
|
|
{
|
|
Startup += new StartupEventHandler(App_Startup);
|
|
}
|
|
/// <summary>
|
|
/// 程序启动初始化
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void App_Startup(object sender, StartupEventArgs e)
|
|
{
|
|
mutex = new System.Threading.Mutex(true, "ConnectPoint", out bool ret);
|
|
if (!ret)
|
|
{
|
|
//ActivateOtherWindow();
|
|
Environment.Exit(0);
|
|
}
|
|
else
|
|
{
|
|
MainWindow _MainWindow = new MainWindow
|
|
{
|
|
WindowStyle = WindowStyle.None,
|
|
WindowState = WindowState.Minimized,
|
|
ShowInTaskbar = false
|
|
};
|
|
_MainWindow.Show();
|
|
}
|
|
}
|
|
}
|
|
}
|