Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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 :)

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

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top