PDA

View Full Version : any way to catch error message from dll in a gui app?



lvdong
24th October 2010, 07:33
I'm using QLibrary to load a dll in a gui app, the problem is how to catch the error message in stderr from the dll.

dll.cpp
...
std::cerr << "error!" << std::endl;
...

I tried using QFile to open the stderr, but got nothing.
file.open(stderr, QIODevice::ReadOnly);
QByteArray msg = file.readAll();

Thanks!

tbscope
24th October 2010, 08:45
Try using a textstream connected to StdErr

wysota
24th October 2010, 10:49
As far as I know stderr is a write-only stream so if something has already been sent to stderr, you won't be able to retrieve it in the same process. But you should be able to redefine std::cerr to something else and intercept the text before it reaches stderr. This is strictly a C++ issue though.