473,440 Members | 1,792 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,440 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 5213
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.