MFC C++: TODO<文件描述>已停止工作文件描述>
我编写了一个程序,尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
解决方案是不要写入
C:\Windows
文件夹。您不是为 Microsoft Windows 团队工作。The solution is not to write to the
C:\Windows
folder. You're not working for the Microsoft Windows team.您为客户提供了“TODO:...”产品,这真是太棒了?请编辑版本信息以反映您的产品名称〜
至于崩溃情况:
/DEBUG
标志来启用 PDB 文件生成(这与编译器设置中的 _DEBUG 宏不相同!)。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:
/DEBUG
flag in linker setting (this is not same as _DEBUG macro in compiler settings!).有几个可能的原因,其中没有写入权限(可能运行程序的用户没有对 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.
是否有可能您已关闭 UAC,但您的客户端却没有?或者,客户的用户是否没有管理权限?不允许用户进程写入 c:\Windows 文件夹。如果是这种情况,尝试创建文件将引发异常。
创建数据文件的正确位置是:
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:
除了权限问题之外,导致应用程序崩溃的第一件事就是客户端的 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?
“我编写了一个程序,尝试在 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.