如何隐藏控制台窗口并调出启动屏幕?
我使用 Matlab 编译器创建了一个 .exe 文件。 该程序需要 15 秒才能启动。 我想隐藏控制台窗口,并显示自定义启动屏幕。 我怎样才能做到这一点?
I've used the Matlab Compiler to create a .exe file. The program takes 15 sec to start. I would like to hide the console window, and display a custom splash screen. How can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
关于制作启动画面,The MathWorks File Exchange 上有一些提交内容处理这个问题:
我个人没有使用过它们中的任何一个,但如果您想设计自己的闪屏功能,它们至少应该为您提供一些指导。
With regard to making a splash screen, there are a few submissions on The MathWorks File Exchange that deal with just that:
I haven't used any of them personally, but they should at the very least give you some guidance if you want to design your own splash screen functionality.
您可以编写一个“启动器”程序。
启动器将
棘手的一点是确定 matlab 程序何时启动。 一种方法可能是循环调用 EnumWindows() 和 GetWindowText(),查找 matlab 窗口标题,但如果您了解 matlab 程序的用途,您也许能够想出更好的方法。
您可能需要不断检查 matlab 进程是否已终止,以防出现问题。
You can write a "launcher" program.
The launcher would
The tricky bit will be determining when the matlab program has started. One method might be to call EnumWindows() and GetWindowText() in a loop, looking for the matlab window title, but you might be able to come up with a better way given knowledge of what the matlab program does.
You would probably need to keep checking that the matlab process hasn't died, in case something goes wrong.
要摆脱 DOS 窗口,请使用
mcc -e
而不是mcc -m
。 请参阅由doc()
提供的在线文档中的“MATLAB 编译器 > 函数参考”。 不过,您可能不想这样做:DOS 窗口是最后的输出; 这是未处理的异常、核心转储和其他诊断输出所在的位置。 至少让它成为一个选项,这样您就可以拥有带有 DOS 窗口的调试版本。根据我的经验,编译的独立 Matlab 程序的启动开销发生在控制权转移到用户 M 代码之前,因此启动屏幕需要在外部程序中完成,或者挂接到
mcc< 的 C 包装器中/code> 生成。 您可以使用 Michael J 编写启动器的建议。 不过,您并不是在寻找
matlab.exe
或 Matlab 桌面窗口,因为这是一个独立的应用程序。 要检测 Matlab 程序何时启动,请让您的 M 代码作为程序执行的第一件事写出一个小临时文件,并让您的启动器监视该文件。To get rid of the DOS window, use
mcc -e
instead ofmcc -m
. See "MATLAB Compiler > Function Reference" in the online documentation, brought up bydoc()
. You might not want to do that, though: the DOS window is the output of last resort; it's where unhandled exceptions, core dumps, and other diagnostic output go. At least make it an option so you can have a debug build that has the DOS window.In my experience, the startup overhead for a compiled standalone Matlab program happens before control transfers to user M-code, so a splash screen will need to be done in an external program, or hooked in to the C wrapper that
mcc
generates. You could use Michael J's suggestion of writing a launcher. You're not looking formatlab.exe
or a Matlab desktop window, though, since this is a standalone app. To detect when the Matlab program has started, have your M-code write out a little temp file as the first thing the program does, and have your launcher watch for that.