gpt4 book ai didi

c# - process.MainWindowHandle 为零?

转载 作者:太空宇宙 更新时间:2023-11-03 20:07:15 29 4
gpt4 key购买 nike

为什么 process.MainWindowHandle 在下面的代码中为零?

Process me = Process.GetCurrentProcess();
foreach (Process process in Process.GetProcessesByName(me.ProcessName))
{
if (process.Id != me.Id)
{
MessageBox.Show(string.Format("{0}", process.MainWindowHandle));
ShowWindow(process.MainWindowHandle, 5);
ShowWindow(process.MainWindowHandle,3);
SetForegroundWindow(process.MainWindowHandle);
break;
}
}

最佳答案

隐藏窗口是一个非常重要的细节。

来自MSDN article on the Process.MainWindowHandle Property :

A process has a main window associated with it only if the process has a graphical interface. If the associated process does not have a main window, the MainWindowHandle value is zero. The value is also zero for processes that have been hidden, that is, processes that are not visible in the taskbar.

关于c# - process.MainWindowHandle 为零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22373025/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com