Re: CreateProcess in a loop
Gentlemen, I spotted the problem. Life of a programmer-creating hell
and then figuring out how the hell did I do that. :o) Inside this
loop, I was overwriting the actual command with junk that was being
issued in CreateProcess function.
STARTUPINFO si;
PROCESS_INFORMATION pi;
int i = 0;
while ( i < 6 )
{
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
CreateProcess(function arguments);
WaitForSingleObject(some arguments);
// HERE I MESSED UP
// I changed the argument(command) being fed into CreateProcess to
some junk value. So when loop is executed
// again the command which suppose to be executed is lost.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
i++;
}
Since we are at this junction, I will explain what I am doing. My
goal with this code is to ping a network drive. If I am able to ping
it, then I derive at two logical conclusions, (1) I have a valid IP
assigned by DHCP and (2) I can run the code to map it. My real goal
is to detect if I have a valid IP address. Since currently I don't
know of any other method, I ping some server on network by the code
above. If anyone can suggest better alternatives, I am very
interested. Thanks for your comments/suggestions/questions. I
learned there are better ways of doing what I am doing.