user1028435
user1028435

Reputation: 309

Writing to Console from DLL

I have a DLL for a program, and want to be able to run that program in a command line, and then pipe the output of my DLL to another program. How do I do this?

I can currently opening a new debug console to print to, but I want to be able to pipe the output so that I can run a shortcut like:

C:\Windows\System32\cmd.exe /K "C:\Program_Using_the_DLL.exe | C:\Program_to_Pipe_To.exe"

This is different from some similar questions (IE: this one) in that I need to be able to pipe the output, so I need it to come to the current console.

Perhaps I can use GetStdHandle() somehow, or is there someway of using AttachConsole(ATTACH_PARENT_PROCESS)? Any help would be appreciated! I'm new to this nitty-gritty part.

(DLL is written in C++)

Upvotes: 2

Views: 2989

Answers (1)

Mark Ransom
Mark Ransom

Reputation: 308158

Try using the function GetStdHandle(STD_OUTPUT_HANDLE) to get a HANDLE to the current output file.

Upvotes: 2

Related Questions