In the previous blog, I wrote a process that could not be killed. Now I want to write another folder that cannot be deleted (the file is the same). The so-called "no" can be deleted, but "deleted" can be deleted, and then created again immediately. The Code is as follows:
# Include <stdio. h> # include <windows. h> # include <io. h> // For access () # define _ CRT_SECURE_NO_WARNINGS // eliminate compiler warnings, such as fopen being insecure // determine whether bool checkFileExist (const char * fileName) exists in the file or file directory) // case insensitive {if (access (fileName, 0) // parameter 0 indicates the existence of the check file {return false;} return true;} int main () {char * logFile = "D: \ Log"; while (1) {if (! CheckFileExist (logFile) // If the folder does not exist, re-create {CreateDirectory (logFile, NULL); // parameter: folder name, Security Attribute} Sleep (100 );} return 0 ;}
To delete this folder, you must end the process. If the process failed to kill the process by using the method described in the previous article, it is really difficult to delete the folder. First, delete the folder, and the process immediately recreates the folder. Second, the process is killed, and another process is immediately restored. Third, another process is killed, the process immediately restores another process. In this way, mutual calls are mutually protected, and the deletion cannot be deleted, and the kill cannot be killed.