CWinApp :: ExitInstance()不能杀死Win 7中的进程 [英] CWinApp::ExitInstance() is not Killing the Process in win 7

查看:153
本文介绍了CWinApp :: ExitInstance()不能杀死Win 7中的进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



为了关闭.exe文件,我正在使用CWinApp::ExitInstance().
这里的问题是,正在调用ExitInstance()方法,并且返回值为零.但是当我签入taskmanager时,exe仍在运行.使用的操作系统是Windows7.在Windows XP中也可以正常工作.看看此处 [ http://msdn.microsoft.com/zh-CN /library/ms644945(v=vs.85).aspx [ ^ ](假设您的应用程序只有一个线程).


看起来您对我不满意,因为您没有喜欢我的答案,或者我提供的链接.

SrikanthSriSri写道:但是使用相同的API ExitInstance(),该exe在客户版本中被杀死,而在开发人员版本中则没有发生.有任何想法吗?


是的,您的代码是错误的.它有时在某些情况下可以工作的事实并不意味着该代码正确无误,只是表明该错误没有出现.如果您花时间参考我发布的链接,则会看到以下句子:
每次由于您退出应用程序而导致应用程序副本终止时,都会调用CWinApp类的ExitInstance成员函数.


对我来说,这表明调用此函数并不一定会终止程序.调试器的咒语应该可以确认这一点.


Hi,

In order to close the .exe file, i am using CWinApp::ExitInstance().
The Problem here is, ExitInstance() method is being called and the return value is zero. But when i check in taskmanager the exe is still running. Operating system used is Windows 7. Also it was working fine in windows XP.

解决方案

I don''t think that is correct; take a look here[^] for information on this member function.


To close an application you need to send quit message.
Calling ExitInstance won''t help. try calling PostQuitMessage function http://msdn.microsoft.com/en-us/library/ms644945(v=vs.85).aspx[^](assuming your application has only single thread).


Well it looks like you downvoted me because you did not like my answer, or maybe the link I provided.

SrikanthSriSri wrote: But with the same API ExitInstance() the exe is getting killed in customer version but not happening in developer version. Any Idea y ?


Yes, your code is wrong. The fact that it sometimes works under certain circumstances does not mean that the code is correct, only that the error is not showing up. If you took the time to refer to the link I posted you will see the following sentence:
The ExitInstance member function of class CWinApp is called each time a copy of your application terminates, usually as a result of the user quitting the application.


That suggests to me that calling this function does not necessarily terminate the program. A spell with the debugger should confirm this.


这篇关于CWinApp :: ExitInstance()不能杀死Win 7中的进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆