捕获VC ++应用程序中DLL的控制台输出 [英] Capturing console output of a DLL in a VC++ Application

查看:324
本文介绍了捕获VC ++应用程序中DLL的控制台输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个VC ++控制台应用程序,该应用程序需要捕获另一个dll的控制台输出. (dll方法具有几个printf函数).


Hi,

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


//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 );
}



如何实现以上目标? (我无法修改dll)

[
DLL函数的签名为
1个无效的dll_callA(char *字符串)和
2 void dll_callB(char * string)?
他们内部有控制台printf调用,我需要捕获
]

谢谢



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

推荐答案



如果我正确理解您的问题,则希望将dll的stdout重定向到可以读取的流.

这需要两个程序:

1个 ProgA 受控程序,该程序与dll链接并对其进行操作,并调用void dll_callA(char* string)等...

2一个控制程序,该程序以重定向的stdout启动 ProgA ;请参见使用重定向的输入和输出创建子进程 [ ^ ]以获得详细说明.

欢呼声,
AR
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


这篇关于捕获VC ++应用程序中DLL的控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆