C++将窗口传递给新的 exe
因此,我的问题是当前在Windows上的目标,但是了解OSX的信息仍然很有用,因为以后知道您有答案。
我的程序如何功能: 初始EXE将运行并创建一个窗口,此EXE将检查并执行主程序的更新并进行一些用户输入。用户输入后,此EXE将启动一个新的EXE(主程序),从窗口传递详细信息,以便该新的EXE可以要求窗口并使用它。第一个程序将终止,窗口不应关闭。
我需要的帮助: 我知道如何创建窗口,并通过EXE传递所需的参数并不是我所知道的,但是我不认为我会很难找到和使用该信息。我的主要问题是,当第一个EXE终止时,如何阻止窗口关闭,因为OS可能会自动开始清理内容。
sidenotes: 这没什么大不了的,我总是可以启动一个新程序并重新创建一个窗口,但是我认为这只是一个不必关闭窗户,保持活力并被不同程序处理的美学触摸是一种不错的美感。同时)。
我的印象是,即使不使用所需的文件/信息/编译代码,EXE也无法自行更新,因此,如果这是错误的,请告诉我。
So my question is targeted currently at Windows, but knowing the information for OSX would still be useful just to know later incase you have the answer for that.
How my program(s) function:
An initial EXE will run and create a window, this EXE will check and perform updates for the main program and take some user input. After the user input this EXE will start a new EXE (the main program), passing the details from the window so that this new EXE can claim the window and use it. The first program will terminate and the window should not close.
What I need help with:
I know how to create the window, and passing the required arguments through the exe is not something I know, but I dont think I will struggle to find and use that information. My main question is how do I stop the Window from closing when the first EXE terminates because likely the OS will automatically start cleaning things up.
Sidenotes:
Its not a super big deal, I can always start a new program and recreate a window, but I think it would just be a nice aesthetic touch to not have to close the window at all, staying alive and being handled by different programs(potentially at the same time).
I am under the impression that an EXE cannot update itself while running even if the needed files/information/compiled code are not being used so if this is wrong please let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您要做的事情不能做。您无法将窗口的所有权转移到其他线程。这可以从 DestroyWindows :
雷蒙德·陈(Raymond Chen)在他的博客条目中解释了这一点,标题为接口对象,第1部分:窗口句柄:
就操作系统而言, nothing 在过程的结束时生存下来。这实际上是结局。如果您需要保留一个窗口,则无法终止拥有其所有线程的过程。
What you're trying to do cannot be done. You cannot transfer ownership of a window to a different thread. This can be inferred from the documentation of
DestroyWindows
:Raymond Chen expands on this as he explains in his blog entry titled Thread affinity of user interface objects, part 1: Window handles:
As far as the OS is concerned, nothing survives the end of a process. This is literally the end. If you need to keep a window around, you cannot terminate the process that owns its owning thread.