CreateProcess Loop Problem (Visual C++ 2005)

Discussion in 'C++' started by wtfdan@gmail.com, Feb 13, 2007.

  1. Guest

    When I call the method perform_single_upload() in this loop:

    ----------------------------
    private: System::Void start_uploads(int i)
    {
    i = 0;
    while(i < master_list->Length)
    {
    //Create a single batch file containing the upload instructions
    create_single_upload(i);
    //Increment loading bar
    pb_Progress->Value::set(pb_Progress->Value::get() + 1);

    //Load and perform the batch file contents
    perform_single_upload();
    //Increment loading bar
    pb_Progress->Value::set(pb_Progress->Value::get() + 1);

    //Delete the batch file in preparation for the next one
    cleanup_upload();
    //Increment loading bar
    pb_Progress->Value::set(pb_Progress->Value::get() + 1);

    i++;
    }
    }
    ----------------------------

    With perform_single_upload() doing the following:

    ----------------------------
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    LPTSTR szCmdline=_tcsdup(TEXT("upload.bat"));

    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    // Start the child process.
    if( !CreateProcess( NULL, // No module name (use command line)
    szCmdline, // Command line
    NULL, // Process handle not inheritable
    NULL, // Thread handle not inheritable
    FALSE, // Set handle inheritance to FALSE
    0, // No creation flags
    NULL, // Use parent's environment block
    NULL, // Use parent's starting directory
    &si, // Pointer to STARTUPINFO structure
    &pi ) // Pointer to PROCESS_INFORMATION structure
    )
    {
    //Something went wrong.
    AnError^ uploaderror = gcnew AnError();

    uploaderror->label1->Text::set("There was an error finding a batch
    script file.");
    uploaderror->ShowDialog();
    return;
    }

    // Wait until child process exits.
    WaitForSingleObject(pi.hProcess, INFINITE);

    // Close process and thread handles.
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
    ----------------------------

    ....my main process appears frozen until the loop in the first method
    has gone through all of its iterations. I can't seem to figure out
    why it doesn't update anything after calling the
    perform_single_upload() method for the first time.

    Is there any way to maintain control of my main application after a
    CreateProcess(), or system(), or WinExec(), etc. call?
    , Feb 13, 2007
    #1
    1. Advertising

  2. Guest

    It appears I need to be pumping messages... though I have no idea what
    this means.
    , Feb 13, 2007
    #2
    1. Advertising

  3. Ian Collins Guest

    wrote:
    > When I call the method perform_single_upload() in this loop:
    >

    Looks like you want a windows programming group.

    --
    Ian Collins.
    Ian Collins, Feb 14, 2007
    #3
  4. red floyd Guest

    wrote:
    >
    > [redacted]
    >
    > Is there any way to maintain control of my main application after a
    > CreateProcess(), or system(), or WinExec(), etc. call?
    >


    The Windows API is off-topic for comp.lang.c++. May I suggest a Windows
    specific newsgroup? A partial list of suggestions may be found at
    http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.9
    red floyd, Feb 14, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kroum Grigorov
    Replies:
    1
    Views:
    700
    Christopher Benson-Manica
    Apr 26, 2004
  2. Elly Sokol

    CreateProcess

    Elly Sokol, Jun 17, 2004, in forum: C++
    Replies:
    13
    Views:
    4,412
    Frederic Banaszak
    Jun 18, 2004
  3. Baskar

    Createprocess

    Baskar, Jan 20, 2005, in forum: C++
    Replies:
    1
    Views:
    446
    Victor Bazarov
    Jan 20, 2005
  4. Replies:
    0
    Views:
    340
  5. Isaac Won
    Replies:
    9
    Views:
    369
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page