If you don't mind using multithreaded solution, you can do it something like this:
Put this at the beginning of the file:
Code:
#include <process.h>
void name(void *P);
Put this where you want to start trying to create the file:
Code:
_beginthread(name,0,NULL);
And you can put this to the end of the file then:
Code:
void name(void *P){
while(CreateFile("filename.txt",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_WRITE|FILE_ SHARE_READ,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMA L,NULL)==INVALID_HANDLE_VALUE){
}
dosomethingornotifytherestoftheprogram
}
This can be very succesfully used with WIN32 GUI applications.