473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CreateProcess Loop Problem (Visual C++ 2005)

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 '07 #1
3 5211
It appears I need to be pumping messages... though I have no idea what
this means.

Feb 14 '07 #2
wt****@gmail.com wrote:
When I call the method perform_single_upload() in this loop:
Looks like you want a windows programming group.

--
Ian Collins.
Feb 14 '07 #3
wt****@gmail.com 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-lit...t.html#faq-5.9
Feb 14 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Achim Domma | last post by:
Hi, I try to start a process on windows using win32process.CreateProcess and want to to redirect the output. I set the STARTF_USESTDHANDLES flag in the STARTUPINFO structure. But I can not...
0
by: ByteSize | last post by:
Would be grateful of advice please. I have code in VB6 working as follows: lngReply = CreateProcess(sNull, txtStart, ByVal 0&, ByVal 0&, 1&, _ NORMAL_PRIORITY_CLASS, ByVal 0&, sNull, sInfo,...
1
by: DOT NET JIM | last post by:
in VB6 the api declares the createprocess lbEnv var as any. When converted to ..NET is change the type any to Object. The problem is, what kind of object. I can not get the env variables set when...
1
by: Baskar | last post by:
Hi, My requirement is I have to run n number of precess in a loop. But all processes should run in a chained manner, I mean only after the previous process gets completed the next process should...
3
by: kal | last post by:
Hi, I am trying to write an application that will launch a second application using CreateProcess... SECURITY_ATTRIBUTES sa; STARTUPINFO si; PROCESS_INFORMATION pi; ::ZeroMemory( &sa,...
5
by: Stefano Camaiani | last post by:
Hello, please someone have the working code on how to call the CreateProcess API in Vb.Net? I need to call the CreateProcess API directly and i should not use the Vb.Net Process functions like dim...
2
by: Paul Schenk | last post by:
Hi All :) Would be grateful of advice please. I have code in VB6 working as follows: lngReply = CreateProcess(sNull, txtStart, ByVal 0&, ByVal 0&, 1&, _ NORMAL_PRIORITY_CLASS, ByVal 0&,...
1
by: Jai | last post by:
Please provide sample code for using Createprocess in VB.NET. The code I am using is given below. But I get "Error 91: Object referrence not set to an instance of the object" at CreateProcess...
0
by: wtfdan | last post by:
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.