Jump to content
  • Advertisement
Sign in to follow this  
geekalert

Deleting yourself (and no I'm not a nihilist)

This topic is 4771 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When uninstalling a program, not only do you delete the application's files, the uninstall program also deletes itself. How would you do that? My basic implementation is to use DeleteFile, but apparently, the file needs to be closed before deleting, so the caller program cannot delete itself. My program is intended to self-liquidate (obviously (see title)), so none of that "use an external program on a CD" crap. Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
From MSDN: "The DeleteFile function marks a file for deletion on close. Therefore, the file deletion does not occur until the last handle to the file is closed."

Share this post


Link to post
Share on other sites
That's interesting... it doesn't work for me. Here's a code snippet:

/* uninstalltest.cpp */

DeleteFile("uninstalltest.exe");
ExitProcess(0);

Share this post


Link to post
Share on other sites
Here are a bunch of methods to do what you want. Maybe you'll find one of them to be useful, and not too complex for your needs.

Share this post


Link to post
Share on other sites
Quote:
Original post by geekalert
DeleteFile("uninstalltest.exe");


It's a relative path. Double-check that it points to the correct file in the correct directory.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!