char CurrentPath[MAX_PATH] = {0};
GetModuleFileName(NULL,CurrentPath,MAX_PATH);
char BaseNameA[MAX_PATH] = {0};
GetBaseNameFromPath(CurrentPath,BaseNameA);
if(hFile==NULL)
{
hFile = CreateFile(CurrentPath,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile==INVALID_HANDLE_VALUE)
MessageBox(0,"hFile Failed!",0,0);
}
Hello!
The code above is failing randomly (sometimes it works perfectly, other times it reports "hFile Failed!"). I don't quite understand why it fails at times.
Perhaps I should use C-libraries for opening the current process's file?
Perhaps someone knows a more reliable solution?
Again all I'm trying to do is open the local file of the current process I'm in.
Thank you!