Thread: FILE_FLAG_DELETE_ON_CLOSE doesn't work

  1. #1
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158

    FILE_FLAG_DELETE_ON_CLOSE doesn't work

    I'm trying to make a self deleting executable. By using the "spawn a clone flagged with FILE_FLAG_DELETE_ON_CLOSE" technique. (If you're not familiar with this, look here)
    But the problem is, the FILE_FLAG_DELETE_ON_CLOSE flag only works if the last handle to the file that gets closed is opened with that flag. Making catch22's method inoperable. So, the question is, is there a way to get CreateProcess to open the executable using FILE_FLAG_DELETE_ON_CLOSE internally?

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    So why not use the DELETE_ON_CLOSE method (I don't really get which method you are trying to use, but I'm guessing it's that one)?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by Yarin View Post
    But the problem is, the FILE_FLAG_DELETE_ON_CLOSE flag only works if the last handle to the file that gets closed is opened with that flag. Making catch22's method inoperable.
    This is why.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Wait, CreateFile accepts the flag, not CreateProcess... oops. Sorry.
    You would be right.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 07:48 PM
  2. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 10:50 AM
  3. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 10:39 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. DLL __cdecl doesnt seem to work?
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 08-21-2002, 04:36 PM