Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Capture console output from DLL in C#

Capture console output from DLL in C#

Scheduled Pinned Locked Moved C#
csharpc++tutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RYU
    wrote on last edited by
    #1

    Hi, I have a C++ dll that actually does the console output (either cout or printf). I am just wondering, how to capture this output so I could display it on my text box in C#. Thanks :)

    E 1 Reply Last reply
    0
    • R RYU

      Hi, I have a C++ dll that actually does the console output (either cout or printf). I am just wondering, how to capture this output so I could display it on my text box in C#. Thanks :)

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      Redirect standard input and standard output for the process. Being a Dll makes it more interesting because a dll shouldn't be outputting to standard streams.

      Need a C# Consultant? I'm available.
      Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

      R 1 Reply Last reply
      0
      • E Ennis Ray Lynch Jr

        Redirect standard input and standard output for the process. Being a Dll makes it more interesting because a dll shouldn't be outputting to standard streams.

        Need a C# Consultant? I'm available.
        Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

        R Offline
        R Offline
        RYU
        wrote on last edited by
        #3

        Hi Ennis, How to redirect the standard output? I have been trying to redirect the standard output using Console.SetOut() but it doesn't do much. I am just wondering, what is the standard output in C#? And how to get it? Thanks :)

        E 1 Reply Last reply
        0
        • R RYU

          Hi Ennis, How to redirect the standard output? I have been trying to redirect the standard output using Console.SetOut() but it doesn't do much. I am just wondering, what is the standard output in C#? And how to get it? Thanks :)

          E Offline
          E Offline
          Ennis Ray Lynch Jr
          wrote on last edited by
          #4

          It is done from the Process class which is used to execute executables. Which is why I mentioned my comment about it being odd for a DLL to directly write to STD out.

          Need a C# Consultant? I'm available.
          Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

          R 1 Reply Last reply
          0
          • E Ennis Ray Lynch Jr

            It is done from the Process class which is used to execute executables. Which is why I mentioned my comment about it being odd for a DLL to directly write to STD out.

            Need a C# Consultant? I'm available.
            Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

            R Offline
            R Offline
            RYU
            wrote on last edited by
            #5

            Hi Ennis, I did further testing. When I build my application as console C#, the DLL cout writes the output to the console window. But I can't capture it when I build my C# application as form application :(

            A 1 Reply Last reply
            0
            • R RYU

              Hi Ennis, I did further testing. When I build my application as console C#, the DLL cout writes the output to the console window. But I can't capture it when I build my C# application as form application :(

              A Offline
              A Offline
              alleyes 0
              wrote on last edited by
              #6

              In the Project properties, change the <b>Output Type:</b> to <b>Console Application</b>   You'll get an additional console window in a Winform application.   Ugly for sure but it works.

              Jer 29:11

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups