Jump to content
  • Advertisement
Sign in to follow this  
geekalert

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

This topic is 4888 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!