我有两个独立的进程——一个是控制台应用程序,一个是 winform 应用程序。现在,如果 winform 被最小化,那么控制台应用程序应该对其进行规范化,反之亦然。我怎样才能做到这一点?此外,控制台应用程序启动 winform 并且在启动时它应该处于其规范化位置。我该如何在以下几行中解决这个问题
var processes = Process.GetProcessesByName("MyWinformApp");
if (processes.Length == 0)
{
Process.Start("MyWinformApp.exe");
How to be sure that the winform will open up in Normalized state
}
else
{
IntPtr handle = processes[0].MainWindowHandle;
//If winform minimized the normalize and vice versa ....What to do here
//Maybe use GetWindowPlacement
??
handle = processes[0].MainWindowHandle;
if(if winform was minimized) //how to find this???
{
ShowWindow(handle, Normal);
}
else
{
ShowWindow(handle, Minimize);
}
}
我确实在 pinvoke.net 上找到了信息,但很困惑,所以希望能得到一些帮助。
谢谢