static void Main() { var pcsttoolProcess = Process.GetProcessesByName("pcsttoolform"); if (pcsttoolProcess.Length > 1) { var bProcess = pcsttoolProcess.OrderBy(o => o.StartTime).FirstOrDefault(); var placement = new Windowplacement(); GetWindowPlacement(bProcess.MainWindowHandle, ref placement); if (placement.showCmd == 2) { ShowWindow(bProcess.MainWindowHandle, ShowWindowEnum.Restore); } SetForegroundWindow(bProcess.MainWindowHandle); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FrmMain()); }
static extern bool GetWindowPlacement(IntPtr hWnd, ref Windowplacement lpwndpl);