程序启动时,把其他的程序最小化到任务栏,但是目前的效果是最小化了窗口,并不在任务栏……如图所示为最小化窗口的结果
//const int SW_SHOWMINNOACTIVE = 7;
const int SW_HIDE = 7;
// Hide other windows
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
static void MinimizeWindow(IntPtr handle)
{
ShowWindow(handle, SW_HIDE);
}
public static void MinimizeAll()
{
System.Diagnostics.Process thisProcess = System.Diagnostics.Process.GetCurrentProcess();
System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcesses();
try
{
foreach (System.Diagnostics.Process process in processes)
{
if (process == thisProcess) continue;
System.IntPtr handle = process.MainWindowHandle;
if (handle == System.IntPtr.Zero) continue;
MinimizeWindow(handle);
}
}
catch (Exception ex)
{
//Console.WriteLine(ex.Message.ToString());
}
}
我试过把7改成0,结果最小化的窗口是没了,但是任务栏也跟着不见了,是这个方法本身就无法实现我要的功能,还是ShowWindow的第二参数改成其他数?