Deleting yourself (and no I'm not a nihilist)
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?
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."
That's interesting... it doesn't work for me. Here's a code snippet:
/* uninstalltest.cpp */
DeleteFile("uninstalltest.exe");
ExitProcess(0);
/* uninstalltest.cpp */
DeleteFile("uninstalltest.exe");
ExitProcess(0);
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement