If we want to create a file when the process starts and delete it when the process exits, CreateFile() is convenient to you.
FILE_FLAG_DELETE_ON_CLOSE means the file will be deleted automatically after close hanlde. Even if the process was crashed, it would also be deleted.
Reference in MSDN: