- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
实例 A 正在尝试恢复实例 B 的窗口,但我无法获取实例 B 的窗口句柄。我认为问题是 B 正在使用以下方法将窗口最小化到系统托盘:
this.Visibility = Visibility.Hidden;
A 尝试使用以下方法获取 B 的窗口句柄:
Process process = Process.GetCurrentProcess();
Process.GetProcessesByName(process.ProcessName).First().MainWindowHandle;
等于 IntPtr.Zero
。
我还尝试使用 Spy++ 按类名获取窗口句柄,但类名具有以下格式的每个实例 GUID:
HwndWrapper[FileName.exe;;ad445199-cf93-48a4-bd24-2f97d54c8af8]
最佳答案
那是因为你想要的基本上不存在,而 MainWindowHandle
的概念是一个严重的误称,潜入 .Net Framework 中永远混淆。来自 There can be more than one (or zero): Converting a process to a window :
"I have a thread ID. How do I get the corresponding window?"
You can use the EnumThreadWindows function to get all the windows on the thread.
"Yes, I know about EnumThreadWindows, but how do I get the window that I want?"
Well, you haven't said what you wanted yet.
"I want the window that corresponds to the thread."
But which one? How will you decide among all the windows?
"That's what I'm asking you!"
But you haven't yet described what you want.
"I want the window corresponding to the thread. Why won't you answer my question?"
Note that saying, "I am looking for the top-level unowned window" is a step forward, but it still doesn't uniquely identify a window. There can be multiple top-level unowned windows in a process. For example, Explorer typically has lots of top-level unowned windows. There's the desktop, the taskbar, your open folder windows, and property sheets. If you ask for "the" top-level unowned window of Explorer, which one do you want?
Perhaps people are getting the idea that there is a way to uniquely specify "the" window for a process because the System.Diagnostics.Process object has a property called MainWindowHandle. The documentation for that property doesn't do anything to dispel the notion, either. I have no idea how that property decides among multiple top-level unowned windows.
MSDN 问答中也详细阐述了该主题 Get the Main Window :
Q How can I find the main window for a process? I'm writing a Spy-like tool and I need to get the main window (HWND) for a process so I can send it a message like WM_ACTIVATEAPP.
A Which main window do you mean?
关于c# - 如何将另一个应用程序的窗口句柄最小化到系统托盘?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3721192/
我想在同一运行时间内拥有多种货币。默认节点模板中插入了 Balances 托盘,但如果我正确的话,它只能处理一种货币。 如何多次重复使用托盘? 最佳答案 Pallet 可以实例化,这样您就可以在同一运
我正在尝试使用一段代码打开和关闭计算机的 CD 托盘。我一直在使用 MCI 命令,并将 winmm.lib 包含在我的项目配置的附加依赖项中。我还包含了 windows.h 和 mmsystem.h。
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我正在使用electron-react-boilerplate开发 Electron 应用程序(使用electron-builder打包应用程序)。 我想创建托盘,但是它需要图标路径或 native
有没有办法选择在 Java 中打印时使用哪个出纸盒/托盘?有一个属性 MediaTray 允许您选择输入托盘,但我找不到允许您选择输出的属性。 最佳答案 除了MediaTray , 有一个 Desti
我是一名优秀的程序员,十分优秀!