FILE_FLAG_DELETE_ON_CLOSE doesn't work

This is a discussion on FILE_FLAG_DELETE_ON_CLOSE doesn't work within the Windows Programming forums, part of the Platform Specific Boards category; 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 ...

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

    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?
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,756
    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
    1,664
    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.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,756
    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, 11:39 AM
  5. DLL __cdecl doesnt seem to work?
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 08-21-2002, 04:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21