|
From: Jim Langston on 1 May 2008 01:59 I've been working with a problem and think I'm close to a solution. I'm using a C library in my C++ program, and this C library writes to stdout which I wish to capture into memory for processing in my program instead of displaying. I think I've finally come up with something and want to get anyones opionion before I proceed. 1. createpipe() for stdout 2. create process and have it use the redirected stdout .. This process would simply capture the stdout and write the data into a buffer. 3. Call my external C library function that writes to stdout 4. Close the process that was capturing stdout 5. Read the data in the buffer. Does this sound doable? Has anyone done this before or am I going to have to reinvent the wheel here? Thanks. -- Jim Langston tazmaster(a)rocketmail.com
From: tvamsikalyan on 1 May 2008 05:01 You may want look at # Creating a Child Process with Redirected Input and Output http://msdn.microsoft.com/en-us/library/ms682499(VS.85).aspx Essentially it talks about the same. On May 1, 10:59 am, "Jim Langston" <tazmas...(a)rocketmail.com> wrote: > I've been working with a problem and think I'm close to a solution. I'm > using a C library in my C++ program, and this C library writes to stdout > which I wish to capture into memory for processing in my program instead of > displaying. I think I've finally come up with something and want to get > anyones opionion before I proceed. > > 1. createpipe() for stdout > 2. create process and have it use the redirected stdout > . This process would simply capture the stdout and write the data into a > buffer. > 3. Call my external C library function that writes to stdout > 4. Close the process that was capturing stdout > 5. Read the data in the buffer. > > Does this sound doable? Has anyone done this before or am I going to have > to reinvent the wheel here? > > Thanks. > > -- > Jim Langston > tazmas...(a)rocketmail.com
From: Norman Bullen on 1 May 2008 09:46 Jim Langston wrote: > I've been working with a problem and think I'm close to a solution. I'm > using a C library in my C++ program, and this C library writes to stdout > which I wish to capture into memory for processing in my program instead of > displaying. I think I've finally come up with something and want to get > anyones opionion before I proceed. > > 1. createpipe() for stdout > 2. create process and have it use the redirected stdout > . This process would simply capture the stdout and write the data into a > buffer. > 3. Call my external C library function that writes to stdout > 4. Close the process that was capturing stdout > 5. Read the data in the buffer. > > Does this sound doable? Has anyone done this before or am I going to have > to reinvent the wheel here? > > Thanks. > You will want to call SetStdHandle() in your application to associate STD_ERROR_HANDLE with the pipe. I don't think you need to use a separate process. A second thread in your application could read from the pipe and store the data into a buffer. Norm -- Norm To reply, change domain to an adult feline.
|
Pages: 1 Prev: Best way for C# application to access VC application Next: how to release memory back to os |