If you mean this if-else:
while (handle != INVALID_HANDLE_VALUE)
{
return 0; if (FindNextFile(handle, &search_data) == FALSE)
{
objlog.WriteToLog("MSG", "autoreboot", "reboot done");
system("DEL /F autorebootlist.txt");
std::remove("restarting.exe");
MySystemShutdown();
return 0;
}
else
{
objlog.WriteToLog("MSG", "autoreboot", "reboot not done");
outputFile << "autorebootlist.txt file missing!!! sorry you cannot reboot!!!";
outputFile.close();
}
}
Of course the program will exit before to enter your if-else statement.
But you have to check better the
warnings that the compiler gives you. I'm sure you got "
Unreachable code", but you ignored it!.
The code to do what you ask should be:
strcat(Path, "\\rebootstatus.txt");
FILE *fp = fopen(Path, "r");
if (fp)
{
fclose(fp);
objlog.WriteToLog("MSG", "autoreboot", "reboot done");
system("DEL /F autorebootlist.txt");
std::remove("restarting.exe"); MySystemShutdown();
return 0;
}
else
{
objlog.WriteToLog("MSG", "autoreboot", "reboot not done");
outputFile << "autorebootlist.txt file missing!!! sorry you cannot reboot!!!";
outputFile.close();
}