应用程序如何在C ++中删除自身及其包含的文件夹? [英] How an application can delete itself and its containing folder in C++?

查看:71
本文介绍了应用程序如何在C ++中删除自身及其包含的文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在创建一个卸载程序,它会删除一些文件及其自身。它还需要删除放置它的文件夹。我正在使用C ++ for Windows开发卸载程序。



我找到了删除文件夹和文件的方法但是我找不到删除应用程序本身的方法还删除包含它的文件夹。



任何人都可以指导我如何实现这个目标?



谢谢

解决方案

你是如何创建卸载程序的?通常,您将创建一个使用 Windows Installer 的安装程序,然后这将处理删除安装程序卸载后。


好的......看看这里Self Deleting Exe ...许多方法







http://www.catch22。 net / tuts / self-deletion-executables [ ^ ]


创建名为test.bat的bat文件并在文件中添加:

 del c:\\ example@ / pre>

和c ++

 System :: Diagnostics :: Process :: Start(  c:\\test.bat); 

//等待几秒钟给出错误,所以第二行应该是:

应用程序::退出(); 





i认为它应该有效..无论如何你可以测试它......


Hi,

I am creating an uninstaller which will delete some files and itself. It also needs to delete the folder in which it is placed. I am developing the uninstaller in C++ for Windows only.

I have found methods to delete folders and files but I am not able to find method which deletes the application itself and also deletes the folder that contains it.

Can anyone please guide me how can I achieve this??

Thanks

解决方案

How did you create the uninstaller? Usually, you''d create an installer that is using the Windows Installer, and this will then handle the deletion of the installer after uninstalling.


Ok... Look here Self Deleting Exe... Many Many methods



http://www.catch22.net/tuts/self-deleting-executables[^]


create bat file named : test.bat and add in file this : "

del c:\\example.exe

"
and from c++

System::Diagnostics::Process::Start("c:\\test.bat");

//it wait some sec before gives error so 2nd line should be :

Application::Exit();



i think it should work.. anyway u can test it...


这篇关于应用程序如何在C ++中删除自身及其包含的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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