MFC C++: TODO<文件描述>已停止工作

发布于 2024-11-19 14:26:27 字数 145 浏览 2 评论 0原文

我编写了一个程序,尝试在 C:\windows\ 目录中写入文件。我已经在几台装有 winXP、win7(64 和 32 位)的 PC 上测试了该程序。但是当我将其安装到客户的 PC 中时,它崩溃并显示消息:TODO(文件描述)已停止工作 如果有人知道任何解决方案,请回复我。

I have wrote a program which tries to write a file in C:\windows\ directory. I have tested the program in several PCs with winXP, win7 (64 & 32 bit).But when i install it in my client's PC it crashed with the message : TODO ( file description ) has stopped working
Please if anybudy knows any solution then reply me.

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

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

发布评论

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

评论(6

岁月无声 2024-11-26 14:26:28

解决方案是不要写入 C:\Windows 文件夹。您不是为 Microsoft Windows 团队工作。

The solution is not to write to the C:\Windows folder. You're not working for the Microsoft Windows team.

浪菊怪哟 2024-11-26 14:26:28

您为客户提供了“TODO:...”产品,这真是太棒了?请编辑版本信息以反映您的产品名称〜

至于崩溃情况:

  • 检查您的应用程序是否确实需要管理员权限,如果是,请从“以管理员身份运行”开始,看看是否可以解决问题。
  • 在“停止工作对话框”或 Windows 事件查看器中查看问题详细信息。在两者中,您都可以看到异常代码(如 0xC0000005)和 DLL 名称。为此,您应该通过在链接器设置中启用 /DEBUG 标志来启用 PDB 文件生成(这与编译器设置中的 _DEBUG 宏相同!)。
  • 设置一些文件记录或消息箱(临时),看看程序是否正常运行。是的,您需要进行一些更改,构建并再次提供给您的客户(并且请不要使用“TODO”作为产品名称 - 要专业!)。

It is quite awesome that you gave your client a "TODO:..." product? Please edit the version info to reflect your product name~

As for crash scenario:

  • Check if your application really needs Admin rights, if yes, start with "run as admin" and see it it solves the problem.
  • View the problem details in either "Stopped working dialog box", or in Windows event viewer. In both, you can see the exception code (like 0xC0000005) and the DLL name. For this you should enable PDB file generation by enabling /DEBUG flag in linker setting (this is not same as _DEBUG macro in compiler settings!).
  • Put some file-logging or message-boxing (temporary) and see till where program goes properly. Yes, you need to make few changes, build and give again to your client (and please no "TODO" as product name - be professional!).
不寐倦长更 2024-11-26 14:26:28

有几个可能的原因,其中没有写入权限(可能运行程序的用户没有对 C:\Windows 文件夹的写入权限。请尝试在该位置手动创建文件。)或编程错误。

无论如何,您都可以尝试一些方法来解决问题。如果无法进行调试,您应该将代码的合理部分放入 try catch 块(例如写入文件的部分)。如果发现错误,您可以输出有关错误所在部分的消息。您还应该包含日志记录解决方案并在代码的各个位置添加日志。安装更新的应用程序后,当出现错误时,请在日志文件中查找代码停止的位置。

There are a few possible causes, among them no write access(perhaps the user running the program does not have write access to C:\Windows folder. Try to manually create a file in that location.) or faulty programming.

In any case, you have a few things to try to figure out the problem. If debug is impossible you should put the sensible parts of the code in try catch blocks (for example the part where you write the file). And if error is caught you can output a message about the part where the error is. You should also include a logging solution and add logs in various places of the code. After you install the updated application, when you get an error, look up in the log file to see where the code stopped.

卷耳 2024-11-26 14:26:28

是否有可能您已关闭 UAC,但您的客户端却没有?或者,客户的用户是否没有管理权限?不允许用户进程写入 c:\Windows 文件夹。如果是这种情况,尝试创建文件将引发异常。

创建数据文件的正确位置是:

  1. 用户文件夹下的应用程序数据(如果该文件是针对每个用户的)。
  2. ProgramData (Win7) 或“All Users”(XP) 下的“Application Data”(应用程序数据),如果文件是每个应用程序(日志等)。

Is it possible you have UAC turned off, but your client doesn't? Or, would the client's user not have administrative rights? A user process would not be allowed to write to the c:\Windows folder. If that's the case, trying to create a file would throw an exception.

The proper place to create a data file would be:

  1. Application Data under the user's folder, if the file is per user.
  2. ProgramData (Win7) or Application Data under All Users (XP), if the file is per application (log or so).
各空 2024-11-26 14:26:28

除了权限问题之外,导致应用程序崩溃的第一件事就是客户端的 PC 上未安装运行时。您的安装包是否安装 MSVC 运行时?如果没有,您是否在该 PC 上安装了 MSVC 可再发行运行时?

Apart from the issue of permissions the first thing that will cause your application to crash like that is the runtimes not being installed on your client's PC. Does your install package install the MSVC runtimes? If not, have you installed the MSVC redistributable runtimes on that PC?

蝶…霜飞 2024-11-26 14:26:28

“我编写了一个程序,尝试在 C:\windows\ 目录中写入文件。”

这就是您的问题。不要那样做。

"I have wrote a program which tries to write a file in C:\windows\ directory. "

That's your problem right there. Don't do that.

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