Jump to content

I can just open few processes


MSH

Recommended Posts

this is my code:

 

 

// CreatProcess.cpp : Defines the entry point for the console application.

//

 

#include "stdafx.h"

 

#include <Windows.h>

 

#include <stdio.h>

 

#include <iostream>

 

#include <Psapi.h>

 

#pragma comment(lib,"Psapi")

 

 

 

using namespace std;

 

 

void _tmain(int argc, _TCHAR* argv[])

{

int intNumberofProcesses;

cout << "Enter Number Of Processes:" << endl;

cin >> intNumberofProcesses;

 

STARTUPINFOA startUpInfo = {sizeof(startUpInfo)};

PROCESS_INFORMATION processInfo;

 

int intNumberOfOpenFiles = 0;

 

int processCounter = 0;

 

for(int i = 0; i < intNumberofProcesses;i++)

{

try

{

CreateProcessA("c:\\windows\\system32\\calc.exe", NULL,NULL,NULL,FALSE,NULL,NULL,NULL,&startUpInfo,&processInfo);

intNumberOfOpenFiles++;

}

catch(char * str)

{

 

cout << "Error:" << str << endl;

}

 

unsigned long listOfProccesses[1024];

unsigned long cbNeeded;

 

EnumProcesses(listOfProccesses,sizeof(listOfProccesses),&cbNeeded);

 

unsigned long numberOfProcesses = cbNeeded / sizeof(unsigned long);

 

int calcID = GetProcessId("calc.exe");

 

 

for(unsigned long i = 0 ;i < numberOfProcesses ;i++)

{

if(calcID == listOfProccesses)

{

processCounter++;

}

}

 

}

 

cout << processCounter << endl;

 

 

system("Pause");

}

 

opening 200 processes cause the application crash, but system have enough resources, i don't know why????

 

sorry bot it is not my problem...

 

the same, Excel application.

Excel says "not enough resources"

this occur when just 10% of CPU and ram used...

 

i know this: the desktop heap too have enough resources, and i don't know whats the problem...

 

be or not to be, this is the question...

:-D

Link to comment
Share on other sites

First of all, try to put your codes inside [math] [ code ] .. [/ code ] [/math] brackets,

 

Let me simplify this for you, your program is not the only one processing on your machine,

 

you can use platform-dependent functions to raise the priority of your program in the system, but that's stupid since your program doesn't deserve such thing ...

 

anyway, why'd you want to create 200 programs, it sound futile .. if you want to see the upper limits of your machine, there are tools that can tell you that,

 

those tools won't go create 200+ programs, they will just use equations over resources ...

 

Also, about your code, you are trying to create 200+ copies of a visual application, this will make your environment lag too ...

Edited by khaled
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.