38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
|
using System;
|
|||
|
using Eto.Forms;
|
|||
|
using System.Diagnostics;
|
|||
|
using System.Runtime.InteropServices;
|
|||
|
|
|||
|
namespace UpToolEto.Wpf
|
|||
|
{
|
|||
|
class MainClass
|
|||
|
{
|
|||
|
[STAThread]
|
|||
|
public static void Main(string[] args)
|
|||
|
{
|
|||
|
UpToolEto.Main.Entry(new Application(Eto.Platforms.Wpf), () =>
|
|||
|
{
|
|||
|
Process[] processes = Process.GetProcessesByName("UpTool2");
|
|||
|
if (processes.Length > 0)
|
|||
|
BringProcessToFront(processes[0]);
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
public static void BringProcessToFront(Process process)
|
|||
|
{
|
|||
|
IntPtr handle = process.MainWindowHandle;
|
|||
|
if (IsIconic(handle))
|
|||
|
ShowWindow(handle, 9);
|
|||
|
SetForegroundWindow(handle);
|
|||
|
}
|
|||
|
|
|||
|
[DllImport("User32.dll")]
|
|||
|
private static extern bool SetForegroundWindow(IntPtr handle);
|
|||
|
|
|||
|
[DllImport("User32.dll")]
|
|||
|
private static extern bool ShowWindow(IntPtr handle, int nCmdShow);
|
|||
|
|
|||
|
[DllImport("User32.dll")]
|
|||
|
private static extern bool IsIconic(IntPtr handle);
|
|||
|
}
|
|||
|
}
|