hey,
i think i'm close to getting my program to work but i have a problem. I'm not sure wat to put in the second parameter of waitForMultipleObjects. Can somebody plz tell me.
Here is the code:
Code:
#include <iostream.h>
#include <windows.h>
#include <stdio.h>
int main()
{
PROCESS_INFORMATION pi[5];
int i;
for (i=5; i>0; i--)
{
STARTUPINFO si;
DWORD dwCode = 0;
ZeroMemory ( &si, sizeof ( STARTUPINFO));
si.cb = sizeof ( STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOWNORMAL;
if(CreateProcess ( NULL,
"notepad.exe",
NULL,
NULL,
0,
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&si,
&pi[i]
))
{
cout<<"The ID of notepad is "<<pi[i].dwProcessId <<endl;
}
else
{
cout<< "Error creating process:"<< GetLastError()<<endl;
}
}
for (i=5; i>0; i--)
{
while(WaitForMultipleObjects(5, pi.hProcess,TRUE, 1000) == WAIT_TIMEOUT)
{
cout<<i;
}
cout<<endl;
}
for (i=1, i<6, i++)
{
CloseHandle(pi[i].hThread);
CloseHandle(pi[i].hProcess);
}
}