#include<windows.h>
#include<iostream>
#include<stdio.h>
using namespace std;
int nCloneID,hProcess,hThread,Clone;
void StartClone(int nCloneID){
TCHAR szFilename[MAX_PATH];
::GetModuleFileName(NULL,szFilename,MAX_PATH);
TCHAR szCmdLine[MAX_PATH];
::sprintf(szCmdLine,"\"%s\"%d",szFilename,nCloneID);
STARTUPINFO si;
:: ZeroMemory(reinterpret_cast<void*>(&si),sizeof(si));
si.cb=sizeof(si);
PROCESS_INFORMATION pi;
bool bCreateOK=::CreateProcess(
szFilename,
szCmdLine,
NULL,
NULL,
false,
CREATE_NEW_CONSOLE,
NULL,
NULL,
&si,
&pi);
if(bCreateOK){
::CloseHandle(pi.hProcess);
::CloseHandle(pi.hThread);
}
}
int main(int argc,char* argv[]){
int nClone(0);
if(argc>1){
::sscanf(argv[1],"%d",&nClone);
}
std::cout<<"Process ID: "<<::GetCurrentProcessId()
<<",Clone Id:"<<nClone
<<std::endl;
const int c_nCloneMax=25;
if(nClone<c_nCloneMax)
{
StartClone(++nClone);
}
::Sleep(500);
getchar();
return 0;
}
#include<iostream>
#include<stdio.h>
using namespace std;
int nCloneID,hProcess,hThread,Clone;
void StartClone(int nCloneID){
TCHAR szFilename[MAX_PATH];
::GetModuleFileName(NULL,szFilename,MAX_PATH);
TCHAR szCmdLine[MAX_PATH];
::sprintf(szCmdLine,"\"%s\"%d",szFilename,nCloneID);
STARTUPINFO si;
:: ZeroMemory(reinterpret_cast<void*>(&si),sizeof(si));
si.cb=sizeof(si);
PROCESS_INFORMATION pi;
bool bCreateOK=::CreateProcess(
szFilename,
szCmdLine,
NULL,
NULL,
false,
CREATE_NEW_CONSOLE,
NULL,
NULL,
&si,
&pi);
if(bCreateOK){
::CloseHandle(pi.hProcess);
::CloseHandle(pi.hThread);
}
}
int main(int argc,char* argv[]){
int nClone(0);
if(argc>1){
::sscanf(argv[1],"%d",&nClone);
}
std::cout<<"Process ID: "<<::GetCurrentProcessId()
<<",Clone Id:"<<nClone
<<std::endl;
const int c_nCloneMax=25;
if(nClone<c_nCloneMax)
{
StartClone(++nClone);
}
::Sleep(500);
getchar();
return 0;
}