VC++表单应用程序集中异常处理类似于.net平台上的C#表单应用程序

发布于 2024-09-25 01:02:41 字数 571 浏览 0 评论 0原文

我是 VC++ 新手,并且在 .net 平台上使用 C# 拥有丰富的经验。 目前我正在做一个在.net平台上结合VC++和C#的项目。

我曾经为使用 C# 开发的所有 Windows 窗体应用程序添加集中式异常处理。我所说的集中异常在这里的意思是这样的 http://www.codeproject.com/KB/cs/GlobalExceptionHandling.aspx

现在的问题是在我的新项目中有一个 VC++ 中的遗留应用程序。该项目已进行更改,以便可以在 Visual Studio 2008 中编译,但代码仍然是非托管 VC++。我在当前代码中看到很多 { try catch } 和异常在本地处理,而应用程序不知道后果。

我想知道是否可以向这个遗留的 VC++ 表单应用程序添加集中式异常处理,就像我为 C# 表单应用程序所做的那样(使用 CurrentDomain_UnhandledException 等)。如果是,我在哪里添加此异常处理以及如何添加它。示例插图会有很大帮助。

I am new to VC++ and I have good experience in working with C# on .net platform.
Presently I am in a project which is a combination of VC++ and C# on .net platform.

I used to add centralized exception handling for all windows form applications developed using C#. What I mean by centralized exception here means something like this
http://www.codeproject.com/KB/cs/GlobalExceptionHandling.aspx

Now the problem is in my new project there is a legacy application which is in VC++. Changes have been made in the project so that it compiles in Visual Studio 2008 but the code is still unmanaged VC++. I see a lot of { try catch } in the present code and exceptions being handled locally without the application coming to know of the consequences.

I wanted to know if I can add centralized exception handling to this legacy VC++ forms application like I do for C# forms applications(using CurrentDomain_UnhandledException, etc). If yes where do I add this exception handling and how do I add it. A sample illustration would be of great help.

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

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

发布评论

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

评论(1

神经暖 2024-10-02 01:02:41

您可以利用 set_unexpected (

或者,您可以使用 SetUnhandledExceptionFilter 函数;它使应用程序能够取代进程的每个线程的顶级异常处理程序。

调用该函数后,如果未调试的进程发生异常,并且该异常进入未处理的异常过滤器,则该过滤器将调用lpTopLevelExceptionFilter参数指定的异常过滤器函数。

You can utilize the set_unexpected (<exception>).

Alternatively, you can use SetUnhandledExceptionFilter function; which enables an application to supersede the top-level exception handler of each thread of a process.

After calling this function, if an exception occurs in a process that is not being debugged, and the exception makes it to the unhandled exception filter, that filter will call the exception filter function specified by the lpTopLevelExceptionFilter parameter.

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