如何自定义“%s 遇到问题需要关闭”?

发布于 2024-08-14 03:19:35 字数 495 浏览 5 评论 0原文

每个 Windows 开发人员都非常熟悉以下形式的警报:

Foo.exe 遇到问题,需要关闭。

我对我的应用程序时不时地爆炸(当然仅在开发期间)感到无奈,但当它们发生时,我不想在这里看到“Foo.exe”。我想看到一个“友好”的名称,例如“FooBrowser™”。

我在 MSDN 文档中到处搜索了覆盖该字符串的方法,但没有找到。我进行了大量的实验,看看我是否能在没有运气的情况下偶然发现这个机制。然而,当我在网上搜索“遇到问题并需要关闭”时,我看到很多人在讨论前面带有友好名称的实例,我怀疑他们都用自己的警报替换了整个警报。 :-)

我需要它适用于本机 Win32 应用程序; .NET 不是一个选择。我在网络上看到讨论的一组示例包括 Microsoft Internet Explorer(本机应用程序)和 Microsoft Works(我认为它仍然是本机应用程序,尽管自从我看到它以来已经有四个亿年了)。

秘密握手的秘密是什么?

Every Windows developer is all too familiar with an alert of the form:

Foo.exe has encountered a problem and needs to close.

I am resigned to my apps blowing up from time to time (only during development of course), but when they do, I don't want to see "Foo.exe" here. I want to see a "friendly" name such as "FooBrowser™".

I've searched the MSDN documentation high and low for a way to override this string and not found it. And I've conducted lots of experiments to see if I could stumble across the mechanism without any luck. However, when I search the web for "has encountered a problem and needs to close", I see lots of folks discussing instances preceded by a friendly name, and I doubt they're all replacing the entire alert with their own. :-)

I need this to work for native Win32 applications; .NET ain't an option. The set of examples I see discussed on the web includes Microsoft Internet Explorer (a native app) and Microsoft Works (which I assume is still a native app although it's been four eons since I saw it).

What's the secret handshake?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

彡翼 2024-08-21 03:19:35

我不确定您所针对的 Windows 版本到底是什么,但较新的版本会在您崩溃时尝试使用友好的产品名称。

确保将版本资源添加到可执行文件,并在 FileDescription 字符串中提供友好的产品名称和文件名。

MSDN 上的此页面提供了更多信息。

I'm not sure exactly what version of Windows you are targeting, but newer ones will try to use the friendly product name when you crash.

Make sure you add a version resource to your executable, and provide a friendly product name and file name, in the FileDescription string.

This page on MSDN provides more information.

灼痛 2024-08-21 03:19:35

我的理解是,一旦你的异常冒泡到操作系统,你就不走运了。我的方法是在异常到达操作系统之前捕获它。在我的应用程序中,我有一个表单,当我遇到未处理的异常时,我会显示该表单,该表单允许用户提交错误报告,从而阻止操作系统显示您正在讨论的表单。

只是不同的视角:)

My understanding is that once your exception bubbles up to the OS, you're out of luck. My approach would be to catch the exception before it reaches the OS. In my applications, I have a form that I show when I have an unhandled exception that allows the user to submit bug reports, preventing the OS from showing the form you're talking about.

Just a different perspective :)

过气美图社 2024-08-21 03:19:35

为什么不直接重命名您的应用程序可执行文件 FooBrowser™.exe

Why not just rename your application executable FooBrowser™.exe?

凉栀 2024-08-21 03:19:35

唔。我不知道这是否一定能做到这一点,但值得一试。尝试查看 SetCurrentProcessExplicitAppUserModelID

hmm. I don't know if this is for sure what will do it, but it's worth a try. Try looking into SetCurrentProcessExplicitAppUserModelID

ま柒月 2024-08-21 03:19:35

您是否不能创建一个包含应用程序友好名称的简单字符串资源,并在格式化消息时使用它?

你怎么认为?

希望这有帮助,
此致,
汤姆.

Could you not create a simple string resource that contains the friendly name of your application and use that when formatting the message?

What do you think?

Hope this helps,
Best regards,
Tom.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文