1. There is no ERROR messages appear, but also NO console interface appears;
Win32 GUI apps don't, by default, have a console. If you want to do console output from inside a GUI app then you explicitly need to allocate a console.
For example, from http://stackoverflow.com/questions/3009042/how-to-view-printf-output-in-a-win32-application-on-visual-studio-2010:
void SetStdOutToNewConsole() { int hConHandle; long lStdHandle; FILE *fp; // Allocate a console for this app AllocConsole(); // Redirect unbuffered STDOUT to the console lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE); hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); fp = _fdopen(hConHandle, "w"); *stdout = *fp; setvbuf(stdout, NULL, _IONBF, 0); }
After using SetStdOutToNewConsole(), any subsequent output from your DLL will then appear in a console window. For example:
extern "C" void __stdcall Test() { SetStdOutToNewConsole(); printf("Test message\r\n"); }
Win32 GUI apps don't, by default, have a console. If you want to do console output from inside a GUI app then you explicitly need to allocate a console.
For example, from http://stackoverflow.com/questions/3009042/how-to-view-printf-output-in-a-win32-application-on-visual-studio-2010:
Thank you, jjc.
You give the exactly right answer, and also the links helped a lot.
Win32 GUI apps don't, by default, have a console. If you want to do console output from inside a GUI app then you explicitly need to allocate a console.
For example, from http://stackoverflow.com/questions/3009042/how-to-view-printf-output-in-a-win32-application-on-visual-studio-2010:
After using SetStdOutToNewConsole(), any subsequent output from your DLL will then appear in a console window. For example:
Also, I have anther question concerning the dll-calling in MT4.
Can you go there and have a look?
I think you are a real experts in this field.
Thank you for your help!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
GUYS:
I try to test dll-calling in MQL4, so I build a test dll as following:
What it does is very simple:
1. Output "Hello,World!" from a console interface, and then wait me to press keys;
2. Create a test.txt file in d:\;
And then I use following script to load the dll:
And I got interesting results:
1. There is no ERROR messages appear, but also NO console interface appears;
2. But the test.txt is newly created in d:\;
3. I check the log of MT4, which says:
So I think:
1. The helloworldDLL.dll is successfully called. (so there created the txt file)
2. There's some reason cause the console interface cannot comes out. (I didn't see it, and the getchar() will prevent the console window disappear too quickly thus I can't see it with naked-eyes)
Can anyone tell me the reason?
Thank you in advanced!
Saji from Shanghai