Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a third-party dll that I load into software that isn't mine, and I'm using AllocConsole() to create the standard windows CLI window so I have an easy means of outputting debug messages.

My problem is though, is that it ignores any kind of input. I just want to be able to use the console I allocated and enable the ability for me to give it some input.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
371 views
Welcome To Ask or Share your Answers For Others

1 Answer

Thanks to Ben Voigt, I was able to cause the console to take input after I allocated it by doing:

freopen("CONIN$", "r", stdin); 
freopen("CONOUT$", "w", stdout); 
freopen("CONOUT$", "w", stderr); 

This also directs the stdout and strerr to the same console window, in case they are directed someplace else for some reason.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...