Click here to Skip to main content
15,072,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a VC++ console app, which needs to capture the console output from another dll . (The dll methods has few printf functions).


C++
//psuedo of what I want
mydemoapp() //VC++ console APP
{
   // Here I dont mean to say the function is returning the string.
   // Some mechanism I want here to capture the printfs into buffer1 ( So I used := symbol)
   buffer1 := dll_callA (); //call to another VC++ dll
   printf("output from dll_callA console is %s", buffer1 );

   buffer2 := dll_callB (); //call to another VC++ dll
   printf("output from dll_callB console is %s", buffer2 );
}


How to achieve the above? (I cannot modify dll)

[
The signatures of DLL functions are
1 void dll_callA(char* string) and
2 void dll_callB(char* string)?
They have console printf calls inside, which I need to capture
]

Thanks
Posted
Updated 2-Dec-10 18:27pm
v10
Comments
Alain Rist 2-Dec-10 2:35am
   
What are the signatures of dll_callA() and dll_callB()?
Dalek Dave 2-Dec-10 3:45am
   
Edited to correct Code Block.

1 solution

Hi,

If I understand correctly your problem, you want to redirect your dll's stdout to some stream you can read.

This requires two programs:

1 A ProgA controlled program which links with the dll and operates it, calling void dll_callA(char* string) etc...

2 A controlling program which launches ProgA with redirected stdout; see Creating a Child Process with Redirected Input and Output[^] for detailed instructions.

cheers,
AR
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900